ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1787. Turn for MEGA

This 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 ?
Posted by Donald Cameron 30 Jan 2015 20:49
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