# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
248706 | 2020-07-13T08:11:22 Z | SamAnd | Feast (NOI19_feast) | C++17 | 1000 ms | 9080 KB |
#include <bits/stdc++.h> using namespace std; #define m_p make_pair #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define fi first #define se second typedef long long ll; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); mt19937 rnf(2106); const int N = 300005; const ll INF = 1000000009000000009; int n, k; int a[N]; ll p[N]; ll dp[N]; void solv() { scanf("%d%d", &n, &k); int q = 0; for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); if (a[i] < 0) ++q; } k = min(k, q + 1); for (int i = 1; i <= n; ++i) p[i] = p[i - 1] + a[i]; for (int ii = 0; ii < k; ++ii) { ll maxu = -INF; for (int i = 0; i <= n; ++i) { maxu = max(maxu, dp[i] - p[i]); dp[i] = p[i] + maxu; if (i) dp[i] = max(dp[i], dp[i - 1]); } } printf("%lld\n", dp[n]); } int main() { #ifdef SOMETHING freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #endif // SOMETHING solv(); return 0; } //while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 56 ms | 6264 KB | Output is correct |
2 | Correct | 63 ms | 9080 KB | Output is correct |
3 | Correct | 61 ms | 9080 KB | Output is correct |
4 | Correct | 58 ms | 9080 KB | Output is correct |
5 | Correct | 59 ms | 8952 KB | Output is correct |
6 | Correct | 57 ms | 8824 KB | Output is correct |
7 | Correct | 57 ms | 8824 KB | Output is correct |
8 | Correct | 58 ms | 8952 KB | Output is correct |
9 | Correct | 57 ms | 8824 KB | Output is correct |
10 | Correct | 57 ms | 8952 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 6392 KB | Output is correct |
2 | Correct | 38 ms | 6392 KB | Output is correct |
3 | Correct | 39 ms | 6264 KB | Output is correct |
4 | Correct | 41 ms | 6388 KB | Output is correct |
5 | Correct | 76 ms | 8824 KB | Output is correct |
6 | Correct | 38 ms | 7160 KB | Output is correct |
7 | Correct | 39 ms | 7288 KB | Output is correct |
8 | Correct | 67 ms | 9080 KB | Output is correct |
9 | Correct | 57 ms | 8840 KB | Output is correct |
10 | Correct | 41 ms | 7296 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 63 ms | 6392 KB | Output is correct |
2 | Correct | 64 ms | 6328 KB | Output is correct |
3 | Correct | 64 ms | 6392 KB | Output is correct |
4 | Correct | 63 ms | 6244 KB | Output is correct |
5 | Correct | 66 ms | 6392 KB | Output is correct |
6 | Correct | 63 ms | 6392 KB | Output is correct |
7 | Correct | 63 ms | 6392 KB | Output is correct |
8 | Correct | 62 ms | 6396 KB | Output is correct |
9 | Correct | 67 ms | 6392 KB | Output is correct |
10 | Correct | 63 ms | 6396 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 376 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 0 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 376 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 0 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 9 ms | 512 KB | Output is correct |
23 | Correct | 4 ms | 384 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 2 ms | 384 KB | Output is correct |
27 | Correct | 3 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 56 ms | 6264 KB | Output is correct |
2 | Correct | 63 ms | 9080 KB | Output is correct |
3 | Correct | 61 ms | 9080 KB | Output is correct |
4 | Correct | 58 ms | 9080 KB | Output is correct |
5 | Correct | 59 ms | 8952 KB | Output is correct |
6 | Correct | 57 ms | 8824 KB | Output is correct |
7 | Correct | 57 ms | 8824 KB | Output is correct |
8 | Correct | 58 ms | 8952 KB | Output is correct |
9 | Correct | 57 ms | 8824 KB | Output is correct |
10 | Correct | 57 ms | 8952 KB | Output is correct |
11 | Correct | 40 ms | 6392 KB | Output is correct |
12 | Correct | 38 ms | 6392 KB | Output is correct |
13 | Correct | 39 ms | 6264 KB | Output is correct |
14 | Correct | 41 ms | 6388 KB | Output is correct |
15 | Correct | 76 ms | 8824 KB | Output is correct |
16 | Correct | 38 ms | 7160 KB | Output is correct |
17 | Correct | 39 ms | 7288 KB | Output is correct |
18 | Correct | 67 ms | 9080 KB | Output is correct |
19 | Correct | 57 ms | 8840 KB | Output is correct |
20 | Correct | 41 ms | 7296 KB | Output is correct |
21 | Correct | 63 ms | 6392 KB | Output is correct |
22 | Correct | 64 ms | 6328 KB | Output is correct |
23 | Correct | 64 ms | 6392 KB | Output is correct |
24 | Correct | 63 ms | 6244 KB | Output is correct |
25 | Correct | 66 ms | 6392 KB | Output is correct |
26 | Correct | 63 ms | 6392 KB | Output is correct |
27 | Correct | 63 ms | 6392 KB | Output is correct |
28 | Correct | 62 ms | 6396 KB | Output is correct |
29 | Correct | 67 ms | 6392 KB | Output is correct |
30 | Correct | 63 ms | 6396 KB | Output is correct |
31 | Correct | 0 ms | 384 KB | Output is correct |
32 | Correct | 0 ms | 384 KB | Output is correct |
33 | Correct | 0 ms | 384 KB | Output is correct |
34 | Correct | 0 ms | 384 KB | Output is correct |
35 | Correct | 1 ms | 384 KB | Output is correct |
36 | Correct | 0 ms | 384 KB | Output is correct |
37 | Correct | 0 ms | 384 KB | Output is correct |
38 | Correct | 0 ms | 384 KB | Output is correct |
39 | Correct | 0 ms | 384 KB | Output is correct |
40 | Correct | 0 ms | 384 KB | Output is correct |
41 | Correct | 0 ms | 384 KB | Output is correct |
42 | Correct | 0 ms | 384 KB | Output is correct |
43 | Correct | 1 ms | 384 KB | Output is correct |
44 | Correct | 1 ms | 384 KB | Output is correct |
45 | Correct | 1 ms | 376 KB | Output is correct |
46 | Correct | 0 ms | 384 KB | Output is correct |
47 | Correct | 1 ms | 384 KB | Output is correct |
48 | Correct | 0 ms | 384 KB | Output is correct |
49 | Correct | 1 ms | 384 KB | Output is correct |
50 | Correct | 0 ms | 384 KB | Output is correct |
51 | Correct | 2 ms | 384 KB | Output is correct |
52 | Correct | 9 ms | 512 KB | Output is correct |
53 | Correct | 4 ms | 384 KB | Output is correct |
54 | Correct | 2 ms | 384 KB | Output is correct |
55 | Correct | 3 ms | 384 KB | Output is correct |
56 | Correct | 2 ms | 384 KB | Output is correct |
57 | Correct | 3 ms | 384 KB | Output is correct |
58 | Correct | 1 ms | 384 KB | Output is correct |
59 | Correct | 1 ms | 384 KB | Output is correct |
60 | Correct | 1 ms | 384 KB | Output is correct |
61 | Execution timed out | 1090 ms | 9080 KB | Time limit exceeded |
62 | Halted | 0 ms | 0 KB | - |