# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
477241 |
2021-10-01T11:30:54 Z |
niloyroot |
Feast (NOI19_feast) |
C++14 |
|
40 ms |
312 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;
forp(i,1,n){
cin>>c;
if(c<0){
swap(s1,s2);
} else {
s1+=c;
}
}
if(k==1){
cout<<max(s1,s2)<<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 |
35 ms |
204 KB |
Output is correct |
2 |
Correct |
31 ms |
204 KB |
Output is correct |
3 |
Correct |
35 ms |
204 KB |
Output is correct |
4 |
Correct |
36 ms |
204 KB |
Output is correct |
5 |
Correct |
33 ms |
204 KB |
Output is correct |
6 |
Correct |
31 ms |
204 KB |
Output is correct |
7 |
Correct |
33 ms |
204 KB |
Output is correct |
8 |
Correct |
36 ms |
296 KB |
Output is correct |
9 |
Correct |
34 ms |
312 KB |
Output is correct |
10 |
Correct |
34 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
204 KB |
Output is correct |
2 |
Incorrect |
20 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
292 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
204 KB |
Output is correct |
2 |
Correct |
31 ms |
204 KB |
Output is correct |
3 |
Correct |
35 ms |
204 KB |
Output is correct |
4 |
Correct |
36 ms |
204 KB |
Output is correct |
5 |
Correct |
33 ms |
204 KB |
Output is correct |
6 |
Correct |
31 ms |
204 KB |
Output is correct |
7 |
Correct |
33 ms |
204 KB |
Output is correct |
8 |
Correct |
36 ms |
296 KB |
Output is correct |
9 |
Correct |
34 ms |
312 KB |
Output is correct |
10 |
Correct |
34 ms |
204 KB |
Output is correct |
11 |
Correct |
18 ms |
204 KB |
Output is correct |
12 |
Incorrect |
20 ms |
204 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |