# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
564967 |
2022-05-20T05:41:07 Z |
Cookie |
Feast (NOI19_feast) |
C++14 |
|
124 ms |
5412 KB |
#include <bits/stdc++.h>
using namespace std;
#define LIFESUCKS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define ar array
#include<cstdio>
#define vt vector
#include<fstream>
ifstream fin("closing.in");
ofstream fout("closing.out");
#include<fstream>
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define fi first
#define se second
#define vt vector
using namespace std;
int main()
{
int n, k; cin >> n >> k;
ll a[n];
bool ok = true;
for(int i = 0; i < n; i++){
cin >> a[i];
if(a[i] < 0)ok = false;
}
if(ok || k == 1){
ll mx = a[0], cr = a[0];
for(int i = 1; i < n; i++){
cr = max(cr + a[i], a[i]);
mx = max(mx, cr);
}
cout << mx;
}else{
ll ans = 0;
for(int i = 0; i < n; i++){
if(a[i] >= 0)ans += a[i];
}
cout << ans;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
104 ms |
2560 KB |
Output is correct |
2 |
Correct |
109 ms |
2516 KB |
Output is correct |
3 |
Correct |
107 ms |
2620 KB |
Output is correct |
4 |
Correct |
110 ms |
2612 KB |
Output is correct |
5 |
Correct |
107 ms |
2600 KB |
Output is correct |
6 |
Correct |
112 ms |
2556 KB |
Output is correct |
7 |
Correct |
109 ms |
2516 KB |
Output is correct |
8 |
Correct |
106 ms |
2604 KB |
Output is correct |
9 |
Correct |
105 ms |
2516 KB |
Output is correct |
10 |
Correct |
111 ms |
2588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
2516 KB |
Output is correct |
2 |
Correct |
56 ms |
2644 KB |
Output is correct |
3 |
Correct |
55 ms |
2516 KB |
Output is correct |
4 |
Correct |
58 ms |
2588 KB |
Output is correct |
5 |
Correct |
109 ms |
5360 KB |
Output is correct |
6 |
Correct |
61 ms |
3580 KB |
Output is correct |
7 |
Correct |
60 ms |
3772 KB |
Output is correct |
8 |
Correct |
108 ms |
5412 KB |
Output is correct |
9 |
Correct |
103 ms |
5240 KB |
Output is correct |
10 |
Correct |
57 ms |
3748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
115 ms |
2600 KB |
Output is correct |
2 |
Correct |
112 ms |
2572 KB |
Output is correct |
3 |
Correct |
113 ms |
2516 KB |
Output is correct |
4 |
Correct |
114 ms |
2572 KB |
Output is correct |
5 |
Correct |
118 ms |
2516 KB |
Output is correct |
6 |
Correct |
115 ms |
2604 KB |
Output is correct |
7 |
Correct |
115 ms |
2616 KB |
Output is correct |
8 |
Correct |
112 ms |
2516 KB |
Output is correct |
9 |
Correct |
119 ms |
2644 KB |
Output is correct |
10 |
Correct |
124 ms |
2616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
312 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
312 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
312 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
104 ms |
2560 KB |
Output is correct |
2 |
Correct |
109 ms |
2516 KB |
Output is correct |
3 |
Correct |
107 ms |
2620 KB |
Output is correct |
4 |
Correct |
110 ms |
2612 KB |
Output is correct |
5 |
Correct |
107 ms |
2600 KB |
Output is correct |
6 |
Correct |
112 ms |
2556 KB |
Output is correct |
7 |
Correct |
109 ms |
2516 KB |
Output is correct |
8 |
Correct |
106 ms |
2604 KB |
Output is correct |
9 |
Correct |
105 ms |
2516 KB |
Output is correct |
10 |
Correct |
111 ms |
2588 KB |
Output is correct |
11 |
Correct |
56 ms |
2516 KB |
Output is correct |
12 |
Correct |
56 ms |
2644 KB |
Output is correct |
13 |
Correct |
55 ms |
2516 KB |
Output is correct |
14 |
Correct |
58 ms |
2588 KB |
Output is correct |
15 |
Correct |
109 ms |
5360 KB |
Output is correct |
16 |
Correct |
61 ms |
3580 KB |
Output is correct |
17 |
Correct |
60 ms |
3772 KB |
Output is correct |
18 |
Correct |
108 ms |
5412 KB |
Output is correct |
19 |
Correct |
103 ms |
5240 KB |
Output is correct |
20 |
Correct |
57 ms |
3748 KB |
Output is correct |
21 |
Correct |
115 ms |
2600 KB |
Output is correct |
22 |
Correct |
112 ms |
2572 KB |
Output is correct |
23 |
Correct |
113 ms |
2516 KB |
Output is correct |
24 |
Correct |
114 ms |
2572 KB |
Output is correct |
25 |
Correct |
118 ms |
2516 KB |
Output is correct |
26 |
Correct |
115 ms |
2604 KB |
Output is correct |
27 |
Correct |
115 ms |
2616 KB |
Output is correct |
28 |
Correct |
112 ms |
2516 KB |
Output is correct |
29 |
Correct |
119 ms |
2644 KB |
Output is correct |
30 |
Correct |
124 ms |
2616 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
212 KB |
Output is correct |
33 |
Incorrect |
1 ms |
312 KB |
Output isn't correct |
34 |
Halted |
0 ms |
0 KB |
- |