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

Sri Praneeth Iyyapu Whats wrong with my code- Failing Test 6! [1] // Problem 1787. Turn for MEGA 21 Feb 2015 01:16
Whats wrong with my code. I get correct answer for Test 6 on my compiler, but when I submit the solution, I get wrong answer. Please help!!

I tried with below values and got correct answer
4 3
3 4 5

Correct answer: 1

#include <iostream>
using namespace std;
int main()
{
    int a,k,n,d;
    int b=0;
    cin>>k>>n>>d;
    for (int i=0;i<n-1;i++)
    {
        cin>>a;
        a=a-k;
        b=b+a;
    }
    if (d-k>=0)
    {
        if (b+d-k>=0)
        cout<<b+d-k;
        else cout<<0;
    }


    else if (b>0) cout<<b;
    else cout<<0;
    char f;
    cin>>f;

}
Artem Muzychenko Re: Whats wrong with my code- Failing Test 6! // Problem 1787. Turn for MEGA 10 Jun 2016 22:26
I have some problem, try 5 4 3 , you must have 0.