# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
833130 |
2023-08-22T01:56:43 Z |
veehj |
Feast (NOI19_feast) |
C++17 |
|
1000 ms |
5000 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()
int n, k; vector<ll> a;
void f(){
vector<ll> p=a;
for(int i=1; i<n; i++) p[i]+=p[i-1];
ll ans=0;
for(int i=0; i<n; i++){
for(int j=0; j<i; j++){
ans=max(ans, p[i]-p[j]);
}
}
cout << ans << endl;
return;
}
int main(){
cin >> n >> k;
for(int i=0; i<n; i++){
ll x; cin >> x;
a.pb(x);
}
if(k==1) f();
else{
ll cnt=0;
for(int i=0; i<n; i++) if(a[i]>0) cnt+=a[i];
cout << cnt << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
4492 KB |
Output is correct |
2 |
Correct |
80 ms |
4472 KB |
Output is correct |
3 |
Correct |
86 ms |
4408 KB |
Output is correct |
4 |
Correct |
92 ms |
4484 KB |
Output is correct |
5 |
Correct |
82 ms |
4416 KB |
Output is correct |
6 |
Correct |
83 ms |
4448 KB |
Output is correct |
7 |
Correct |
79 ms |
4444 KB |
Output is correct |
8 |
Correct |
86 ms |
4472 KB |
Output is correct |
9 |
Correct |
89 ms |
4652 KB |
Output is correct |
10 |
Correct |
99 ms |
4408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1060 ms |
4932 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1071 ms |
5000 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
4492 KB |
Output is correct |
2 |
Correct |
80 ms |
4472 KB |
Output is correct |
3 |
Correct |
86 ms |
4408 KB |
Output is correct |
4 |
Correct |
92 ms |
4484 KB |
Output is correct |
5 |
Correct |
82 ms |
4416 KB |
Output is correct |
6 |
Correct |
83 ms |
4448 KB |
Output is correct |
7 |
Correct |
79 ms |
4444 KB |
Output is correct |
8 |
Correct |
86 ms |
4472 KB |
Output is correct |
9 |
Correct |
89 ms |
4652 KB |
Output is correct |
10 |
Correct |
99 ms |
4408 KB |
Output is correct |
11 |
Execution timed out |
1060 ms |
4932 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |