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 is wrong?
Posted by Stan 19 Nov 2015 19:56
#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char *argv[]) {
    int k,n,i;
    cin>>k>>n;
    int y[n+1];
    for (i=1;i<=n;++i)
    {
        cin>>y[i];
    }
    for (i=1;i<=n;++i)
    {
        if (y[i]>k) {y[i+1]+=y[i]-k;}
        else {y[i]=0;}
    }
    cout<<y[n+1]<<endl;
    return 0;
}