|
|
back to boardThis keeps getting Wrong Answer error and I couldn't figure out the problem ? Posted by ATTJ 21 Jan 2015 23:22 #include <stdio.h> int main(void) {
int car_num, min, i, arr[100], sum = 0;
scanf("%d %d", &car_num, &min);
for(i = 0; i < min; i++) { scanf("%d", &arr[i]); if(sum + arr[i] - car_num < 0) sum += 0; else sum = sum + arr[i] - car_num; }
printf("%d", sum);
return 0;
} Re: This keeps getting Wrong Answer error and I couldn't figure out the problem ? You're not printing a newline after printing the answer ... though I think the real issue is different: I don't believe you're handling the following cases correctly. Try this test case 5 3 6 1 2 and this one 5 3 6 1 7 Good luck! -- DC Edited by author 30.01.2015 21:10 |
|
|