# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
477244 |
2021-10-01T11:34:03 Z |
niloyroot |
Feast (NOI19_feast) |
C++14 |
|
39 ms |
3100 KB |
#include <bits/stdc++.h>
using namespace std;
#define forp(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define newl '\n'
void solve(){
ll n,k; cin>>n>>k;
ll c,s1=0,s2=0,a=0;
forp(i,1,n){
cin>>c;
if(c<0){
a=c;
swap(s1,s2);
} else {
s1+=c;
}
}
if(k==1){
cout<<max({s1,s2,s1+s2+a})<<newl;
} else {
cout<<s1+s2<<newl;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
204 KB |
Output is correct |
2 |
Correct |
39 ms |
204 KB |
Output is correct |
3 |
Correct |
33 ms |
312 KB |
Output is correct |
4 |
Correct |
33 ms |
308 KB |
Output is correct |
5 |
Correct |
32 ms |
204 KB |
Output is correct |
6 |
Correct |
30 ms |
204 KB |
Output is correct |
7 |
Correct |
30 ms |
204 KB |
Output is correct |
8 |
Correct |
31 ms |
204 KB |
Output is correct |
9 |
Correct |
35 ms |
204 KB |
Output is correct |
10 |
Correct |
30 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
204 KB |
Output is correct |
2 |
Correct |
23 ms |
312 KB |
Output is correct |
3 |
Correct |
25 ms |
316 KB |
Output is correct |
4 |
Correct |
23 ms |
1320 KB |
Output is correct |
5 |
Correct |
34 ms |
2984 KB |
Output is correct |
6 |
Correct |
20 ms |
1360 KB |
Output is correct |
7 |
Correct |
29 ms |
1356 KB |
Output is correct |
8 |
Correct |
35 ms |
3100 KB |
Output is correct |
9 |
Correct |
30 ms |
3020 KB |
Output is correct |
10 |
Correct |
31 ms |
1316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
204 KB |
Output is correct |
2 |
Correct |
39 ms |
204 KB |
Output is correct |
3 |
Correct |
33 ms |
312 KB |
Output is correct |
4 |
Correct |
33 ms |
308 KB |
Output is correct |
5 |
Correct |
32 ms |
204 KB |
Output is correct |
6 |
Correct |
30 ms |
204 KB |
Output is correct |
7 |
Correct |
30 ms |
204 KB |
Output is correct |
8 |
Correct |
31 ms |
204 KB |
Output is correct |
9 |
Correct |
35 ms |
204 KB |
Output is correct |
10 |
Correct |
30 ms |
204 KB |
Output is correct |
11 |
Correct |
19 ms |
204 KB |
Output is correct |
12 |
Correct |
23 ms |
312 KB |
Output is correct |
13 |
Correct |
25 ms |
316 KB |
Output is correct |
14 |
Correct |
23 ms |
1320 KB |
Output is correct |
15 |
Correct |
34 ms |
2984 KB |
Output is correct |
16 |
Correct |
20 ms |
1360 KB |
Output is correct |
17 |
Correct |
29 ms |
1356 KB |
Output is correct |
18 |
Correct |
35 ms |
3100 KB |
Output is correct |
19 |
Correct |
30 ms |
3020 KB |
Output is correct |
20 |
Correct |
31 ms |
1316 KB |
Output is correct |
21 |
Incorrect |
37 ms |
288 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |