TOPIC

100% WA, alguém me diz o que pode estar errado?

drodrigues78 asked 5 years ago

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdbool.h>

typedef struct info {
  int res;
  int cred;
  int deb;
} info;

int main(void) {
  int n, b, i, d;
  while(scanf("%d%d",&b,&n) && (b && n) != 0){
    bool sit = true;
    info banco[b];
    for (i = 0; i < b; i++){
      scanf("%d",&banco[i].res);
    }
    for (i = 0; i < b; i++){
      scanf("%d",&d);
      scanf("%d%d",&banco[d - 1].cred,&banco[d - 1].deb);
    }
    int totalres = n, totaldeb = 0;
    for (i = 0; i < b; i++){
      totalres += banco[i].res;
      totaldeb += banco[i].deb;
    }
    if (totaldeb > totalres){
      sit = false;
    }
    switch(sit){
      case true:
      printf("S\n");
      break;
      case false:
      printf("N\n");
      break;
    }
  }
  return 0;
}

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.