#include<bits/stdc++.h>
using namespace std;
int main()
{
int x;
cin>>x;
int n;
cin>>n;
int a;
int last=0;
for(int i=0;i<n;i++)
{
cin>>a;
last+=x;
last-=a;
last=max(last,0);
}
cout<<last+x<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
360 KB |
Output is correct |
3 |
Correct |
3 ms |
496 KB |
Output is correct |
4 |
Correct |
4 ms |
496 KB |
Output is correct |
5 |
Correct |
3 ms |
496 KB |
Output is correct |
6 |
Correct |
2 ms |
496 KB |
Output is correct |
7 |
Correct |
3 ms |
496 KB |
Output is correct |
8 |
Correct |
3 ms |
496 KB |
Output is correct |
9 |
Correct |
3 ms |
520 KB |
Output is correct |
10 |
Correct |
2 ms |
520 KB |
Output is correct |