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

What problem? Test 3
Posted by Garfield 12 Dec 2016 00:13
#include<iostream>

using namespace std;

int main()
{
    int k, n, a[1010], A, sklad;
    cin >> k >> n;
    if ((1 <= k && k <= 100) && (1 <= n && n <= 100))
    {
        for (int b = 0; b < n; b++)
        {
            cin >> a[b];
        }
        sklad = 0;
        for (int c = 0; c < n; c++)
        {
            A = k - (a[c] + sklad);
            if (A < 0)
            {
                sklad = -A;
            }
            else
                sklad = 0;
        }
        if (A < 0)
        {
            cout << -A;
        }
        else
            cout << A;
    }
    return 0;
}


Re: What problem? Test 3
Posted by Logan`~ 14 Sep 2018 20:31
попробуйте
5 5
0 0 0 0 0