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

Wrong 6
Posted by dima 17 Nov 2012 21:36
This is my code on C++. The wrong is in the test №6. Why? Help me, please.

#include <iostream>

using namespace std;

int main()
{
int k, n, sum=0, a, i, mas[100];
cin >> k >> n;
if (k>=1 && n<=100)
{

for (i=0; i <= n-1; i++)
{
 cin >> mas[i];
 if (mas[i] <= 100 && mas[i] >= 0)
 sum = sum + mas[i];
 else
 continue;
}

a = n * k;

if (sum > a)
 cout << sum - a << endl;
if (sum <= a)
 cout << 0 << endl;


}
return 0;
}