# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
848153 |
2023-09-11T12:49:51 Z |
asd12343 |
Feast (NOI19_feast) |
C++14 |
|
94 ms |
61520 KB |
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
using namespace std;
const int MN = 2e6+5;
const int INF = 0x3f3f3f3f;
#define int long long
#define pb push_back
#define p make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define f(i,a,b) for (int i = a ; i < b ; i++)
#define f1(i,a,b) for (int i = a ; i > b ; i--)
#define f2(i,a,b) for (int i = a ; i <= b ; i++)
#define FILE(X) \
freopen(#X ".INP","r",stdin); \
freopen(#X ".OUT","w",stdout);
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
int random(int l, int r) { return l + rd() % (r - l + 1); }
int a[MN];
int n,k,pos;
int cnt = 0;
int dp[5003][5003];
int pre[MN];
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//FILE(BLUESKY);
bool flag = false;
cin >> n >> k;
for (int i = 1 ; i <= n ; i++) {
cin >> a[i];
pre[i] = pre[i-1] + a[i];
if (a[i] < 0) flag = true,cnt++, pos = i;
}
for (int j = 1; j <= k; ++j){
int cur = 0;
for (int i = 1; i <= n; ++i) {
cur = max(cur, dp[i][j-1] - pre[i]);
dp[i][j] = max(dp[i-1][j], cur + pre[i]);
}
}
cout << dp[n][k];
return 0;
}
Compilation message
feast.cpp: In function 'int main()':
feast.cpp:30:10: warning: variable 'flag' set but not used [-Wunused-but-set-variable]
30 | bool flag = false;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
82 ms |
61264 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
78 ms |
61264 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
94 ms |
61520 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2648 KB |
Output is correct |
8 |
Correct |
1 ms |
2648 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2648 KB |
Output is correct |
8 |
Correct |
1 ms |
2648 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
3672 KB |
Output is correct |
12 |
Correct |
1 ms |
3672 KB |
Output is correct |
13 |
Correct |
1 ms |
3420 KB |
Output is correct |
14 |
Correct |
1 ms |
3676 KB |
Output is correct |
15 |
Correct |
1 ms |
3672 KB |
Output is correct |
16 |
Correct |
1 ms |
3416 KB |
Output is correct |
17 |
Correct |
1 ms |
3672 KB |
Output is correct |
18 |
Correct |
1 ms |
3416 KB |
Output is correct |
19 |
Correct |
1 ms |
3416 KB |
Output is correct |
20 |
Correct |
1 ms |
3672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2648 KB |
Output is correct |
8 |
Correct |
1 ms |
2648 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
3672 KB |
Output is correct |
12 |
Correct |
1 ms |
3672 KB |
Output is correct |
13 |
Correct |
1 ms |
3420 KB |
Output is correct |
14 |
Correct |
1 ms |
3676 KB |
Output is correct |
15 |
Correct |
1 ms |
3672 KB |
Output is correct |
16 |
Correct |
1 ms |
3416 KB |
Output is correct |
17 |
Correct |
1 ms |
3672 KB |
Output is correct |
18 |
Correct |
1 ms |
3416 KB |
Output is correct |
19 |
Correct |
1 ms |
3416 KB |
Output is correct |
20 |
Correct |
1 ms |
3672 KB |
Output is correct |
21 |
Correct |
8 ms |
13400 KB |
Output is correct |
22 |
Correct |
34 ms |
35664 KB |
Output is correct |
23 |
Correct |
10 ms |
16216 KB |
Output is correct |
24 |
Correct |
8 ms |
13656 KB |
Output is correct |
25 |
Correct |
10 ms |
15192 KB |
Output is correct |
26 |
Correct |
7 ms |
13144 KB |
Output is correct |
27 |
Correct |
11 ms |
14936 KB |
Output is correct |
28 |
Correct |
4 ms |
11096 KB |
Output is correct |
29 |
Correct |
4 ms |
10840 KB |
Output is correct |
30 |
Correct |
4 ms |
10328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
82 ms |
61264 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |