# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
157316 | 2019-10-10T15:51:17 Z | karma | 스트랩 (JOI14_straps) | C++14 | 51 ms | 31868 KB |
#include<bits/stdc++.h> #define FileName "test" #define ll long long #define pb emplace_back #define deg first #define c second using namespace std; typedef pair<int, int> pii; const int N = int(4e3) + 2; const int oo = int(2e9) + 7; int f[N][N], Max[N], a[N]; int n, m, res = 0, pre; pii val[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(FileName".inp", "r")) { freopen(FileName".inp", "r", stdin); freopen(FileName".out", "w", stdout); } cin >> n; m = 2 * n; for(int i = 1; i <= n; ++i) { cin >> val[i].deg >> val[i].c; fill(f[i], f[i] + m + 1, -oo); } sort(val + 1, val + n + 1, [](const pii& x, const pii& y) { return x.deg > y.deg; }); /// f(i, j) = max niem vui khi den cai thu i va co j cong ket noi fill(Max, Max + m + 1, -oo); f[0][1] = 0; Max[1] = 0; for(int i = 1; i <= n; ++i) { for(int j = 0; j <= m; ++j) { pre = min(j + 1 - val[i].deg, m); if(pre < 0 || Max[pre] == -oo) continue; res = max(res, (f[i][j] = Max[pre] + val[i].c)); } for(int j = 0; j <= m; ++j) Max[j] = max(Max[j], f[i][j]); } cout << res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 380 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 380 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Incorrect | 2 ms | 376 KB | Output isn't correct |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 892 KB | Output is correct |
3 | Correct | 2 ms | 888 KB | Output is correct |
4 | Correct | 2 ms | 888 KB | Output is correct |
5 | Correct | 2 ms | 888 KB | Output is correct |
6 | Correct | 2 ms | 888 KB | Output is correct |
7 | Correct | 2 ms | 888 KB | Output is correct |
8 | Correct | 16 ms | 12280 KB | Output is correct |
9 | Correct | 16 ms | 12152 KB | Output is correct |
10 | Correct | 17 ms | 12152 KB | Output is correct |
11 | Correct | 17 ms | 12152 KB | Output is correct |
12 | Correct | 47 ms | 31736 KB | Output is correct |
13 | Correct | 47 ms | 31736 KB | Output is correct |
14 | Correct | 47 ms | 31868 KB | Output is correct |
15 | Correct | 47 ms | 31736 KB | Output is correct |
16 | Correct | 47 ms | 31736 KB | Output is correct |
17 | Correct | 47 ms | 31736 KB | Output is correct |
18 | Correct | 47 ms | 31736 KB | Output is correct |
19 | Correct | 48 ms | 31736 KB | Output is correct |
20 | Correct | 48 ms | 31756 KB | Output is correct |
21 | Correct | 49 ms | 31736 KB | Output is correct |
22 | Correct | 47 ms | 31736 KB | Output is correct |
23 | Correct | 51 ms | 31736 KB | Output is correct |
24 | Correct | 47 ms | 31736 KB | Output is correct |
25 | Correct | 50 ms | 31736 KB | Output is correct |
26 | Correct | 48 ms | 31736 KB | Output is correct |
27 | Correct | 49 ms | 31736 KB | Output is correct |
28 | Correct | 48 ms | 31740 KB | Output is correct |
29 | Incorrect | 50 ms | 31736 KB | Output isn't correct |
30 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 760 KB | Output is correct |
2 | Correct | 2 ms | 760 KB | Output is correct |
3 | Correct | 2 ms | 888 KB | Output is correct |
4 | Correct | 2 ms | 760 KB | Output is correct |
5 | Correct | 2 ms | 760 KB | Output is correct |
6 | Correct | 3 ms | 888 KB | Output is correct |
7 | Correct | 2 ms | 760 KB | Output is correct |
8 | Correct | 2 ms | 760 KB | Output is correct |
9 | Correct | 17 ms | 12288 KB | Output is correct |
10 | Correct | 16 ms | 12152 KB | Output is correct |
11 | Correct | 16 ms | 12152 KB | Output is correct |
12 | Correct | 16 ms | 12280 KB | Output is correct |
13 | Correct | 16 ms | 12280 KB | Output is correct |
14 | Correct | 16 ms | 12152 KB | Output is correct |
15 | Correct | 16 ms | 12152 KB | Output is correct |
16 | Correct | 16 ms | 12152 KB | Output is correct |
17 | Correct | 47 ms | 31736 KB | Output is correct |
18 | Correct | 47 ms | 31736 KB | Output is correct |
19 | Correct | 47 ms | 31736 KB | Output is correct |
20 | Correct | 47 ms | 31864 KB | Output is correct |
21 | Correct | 48 ms | 31736 KB | Output is correct |
22 | Correct | 48 ms | 31736 KB | Output is correct |
23 | Correct | 47 ms | 31736 KB | Output is correct |
24 | Correct | 47 ms | 31736 KB | Output is correct |
25 | Correct | 48 ms | 31736 KB | Output is correct |
26 | Correct | 47 ms | 31736 KB | Output is correct |
27 | Correct | 46 ms | 31864 KB | Output is correct |
28 | Correct | 47 ms | 31736 KB | Output is correct |
29 | Correct | 47 ms | 31736 KB | Output is correct |
30 | Correct | 48 ms | 31736 KB | Output is correct |
31 | Correct | 47 ms | 31864 KB | Output is correct |
32 | Correct | 47 ms | 31756 KB | Output is correct |
33 | Correct | 51 ms | 31736 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 31736 KB | Output is correct |
2 | Correct | 47 ms | 31756 KB | Output is correct |
3 | Correct | 48 ms | 31712 KB | Output is correct |
4 | Correct | 47 ms | 31736 KB | Output is correct |
5 | Correct | 50 ms | 31736 KB | Output is correct |
6 | Correct | 50 ms | 31736 KB | Output is correct |
7 | Correct | 49 ms | 31736 KB | Output is correct |
8 | Correct | 49 ms | 31736 KB | Output is correct |
9 | Correct | 49 ms | 31708 KB | Output is correct |
10 | Correct | 50 ms | 31780 KB | Output is correct |
11 | Correct | 50 ms | 31736 KB | Output is correct |
12 | Correct | 50 ms | 31736 KB | Output is correct |
13 | Correct | 50 ms | 31740 KB | Output is correct |
14 | Correct | 49 ms | 31864 KB | Output is correct |
15 | Incorrect | 51 ms | 31708 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |