#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,m,q;
cin >> n >> m >> q;
vector<int> arr(n+1);
for(int i=1;i<=n;i++)cin>>arr[i];
int ans = 0;
int curr = 0;
for(int i=1;i<n;i++){
ans+=arr[i];
curr+=arr[i];
curr-=arr[i+1];
if(curr<0){
ans-=curr;
curr = 0;
}
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
7 ms |
2652 KB |
Output is correct |
3 |
Correct |
7 ms |
2652 KB |
Output is correct |
4 |
Correct |
7 ms |
2532 KB |
Output is correct |
5 |
Correct |
7 ms |
2784 KB |
Output is correct |
6 |
Correct |
7 ms |
2656 KB |
Output is correct |
7 |
Correct |
7 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
7 ms |
2652 KB |
Output is correct |
3 |
Correct |
7 ms |
2652 KB |
Output is correct |
4 |
Correct |
7 ms |
2532 KB |
Output is correct |
5 |
Correct |
7 ms |
2784 KB |
Output is correct |
6 |
Correct |
7 ms |
2656 KB |
Output is correct |
7 |
Correct |
7 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
14 ms |
4196 KB |
Output is correct |
11 |
Correct |
15 ms |
4188 KB |
Output is correct |
12 |
Correct |
14 ms |
3976 KB |
Output is correct |
13 |
Correct |
14 ms |
4188 KB |
Output is correct |
14 |
Correct |
14 ms |
4076 KB |
Output is correct |
15 |
Correct |
15 ms |
4188 KB |
Output is correct |
16 |
Correct |
14 ms |
4188 KB |
Output is correct |
17 |
Correct |
18 ms |
3944 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
7 ms |
2652 KB |
Output is correct |
3 |
Correct |
7 ms |
2652 KB |
Output is correct |
4 |
Correct |
7 ms |
2532 KB |
Output is correct |
5 |
Correct |
7 ms |
2784 KB |
Output is correct |
6 |
Correct |
7 ms |
2656 KB |
Output is correct |
7 |
Correct |
7 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
14 ms |
4196 KB |
Output is correct |
11 |
Correct |
15 ms |
4188 KB |
Output is correct |
12 |
Correct |
14 ms |
3976 KB |
Output is correct |
13 |
Correct |
14 ms |
4188 KB |
Output is correct |
14 |
Correct |
14 ms |
4076 KB |
Output is correct |
15 |
Correct |
15 ms |
4188 KB |
Output is correct |
16 |
Correct |
14 ms |
4188 KB |
Output is correct |
17 |
Correct |
18 ms |
3944 KB |
Output is correct |
18 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
7 ms |
2652 KB |
Output is correct |
3 |
Correct |
7 ms |
2652 KB |
Output is correct |
4 |
Correct |
7 ms |
2532 KB |
Output is correct |
5 |
Correct |
7 ms |
2784 KB |
Output is correct |
6 |
Correct |
7 ms |
2656 KB |
Output is correct |
7 |
Correct |
7 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
14 ms |
4196 KB |
Output is correct |
11 |
Correct |
15 ms |
4188 KB |
Output is correct |
12 |
Correct |
14 ms |
3976 KB |
Output is correct |
13 |
Correct |
14 ms |
4188 KB |
Output is correct |
14 |
Correct |
14 ms |
4076 KB |
Output is correct |
15 |
Correct |
15 ms |
4188 KB |
Output is correct |
16 |
Correct |
14 ms |
4188 KB |
Output is correct |
17 |
Correct |
18 ms |
3944 KB |
Output is correct |
18 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
7 ms |
2652 KB |
Output is correct |
3 |
Correct |
7 ms |
2652 KB |
Output is correct |
4 |
Correct |
7 ms |
2532 KB |
Output is correct |
5 |
Correct |
7 ms |
2784 KB |
Output is correct |
6 |
Correct |
7 ms |
2656 KB |
Output is correct |
7 |
Correct |
7 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
14 ms |
4196 KB |
Output is correct |
11 |
Correct |
15 ms |
4188 KB |
Output is correct |
12 |
Correct |
14 ms |
3976 KB |
Output is correct |
13 |
Correct |
14 ms |
4188 KB |
Output is correct |
14 |
Correct |
14 ms |
4076 KB |
Output is correct |
15 |
Correct |
15 ms |
4188 KB |
Output is correct |
16 |
Correct |
14 ms |
4188 KB |
Output is correct |
17 |
Correct |
18 ms |
3944 KB |
Output is correct |
18 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |