# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
157317 | 2019-10-10T16:00:32 Z | karma | 스트랩 (JOI14_straps) | C++14 | 267 ms | 157336 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(2e3) + 2; const int oo = int(2e9) + 7; int f[N][N * 10], Max[N * 10], a[N]; int n, res = 0, pre, m; 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 = 10 * 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; } ///4375336
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 | 4 ms | 504 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 504 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 504 KB | Output is correct |
8 | Correct | 2 ms | 504 KB | Output is correct |
9 | Correct | 2 ms | 380 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 504 KB | Output is correct |
12 | Correct | 2 ms | 504 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 504 KB | Output is correct |
15 | Correct | 2 ms | 504 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 504 KB | Output is correct |
18 | Correct | 2 ms | 504 KB | Output is correct |
19 | Correct | 2 ms | 504 KB | Output is correct |
20 | Correct | 1 ms | 504 KB | Output is correct |
21 | Correct | 2 ms | 504 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 504 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 8 ms | 1144 KB | Output is correct |
3 | Correct | 3 ms | 1144 KB | Output is correct |
4 | Correct | 3 ms | 1148 KB | Output is correct |
5 | Correct | 3 ms | 1144 KB | Output is correct |
6 | Correct | 6 ms | 1144 KB | Output is correct |
7 | Correct | 3 ms | 1144 KB | Output is correct |
8 | Correct | 74 ms | 43640 KB | Output is correct |
9 | Correct | 62 ms | 43640 KB | Output is correct |
10 | Correct | 75 ms | 43612 KB | Output is correct |
11 | Correct | 74 ms | 43640 KB | Output is correct |
12 | Correct | 251 ms | 157296 KB | Output is correct |
13 | Correct | 257 ms | 157148 KB | Output is correct |
14 | Correct | 257 ms | 157176 KB | Output is correct |
15 | Correct | 252 ms | 157304 KB | Output is correct |
16 | Correct | 267 ms | 157176 KB | Output is correct |
17 | Correct | 241 ms | 157232 KB | Output is correct |
18 | Correct | 222 ms | 157176 KB | Output is correct |
19 | Correct | 244 ms | 157224 KB | Output is correct |
20 | Correct | 259 ms | 157164 KB | Output is correct |
21 | Correct | 225 ms | 157128 KB | Output is correct |
22 | Correct | 226 ms | 157176 KB | Output is correct |
23 | Correct | 240 ms | 157252 KB | Output is correct |
24 | Correct | 220 ms | 157220 KB | Output is correct |
25 | Correct | 225 ms | 157200 KB | Output is correct |
26 | Correct | 225 ms | 157128 KB | Output is correct |
27 | Correct | 236 ms | 157240 KB | Output is correct |
28 | Correct | 225 ms | 157292 KB | Output is correct |
29 | Incorrect | 252 ms | 157104 KB | Output isn't correct |
30 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1144 KB | Output is correct |
2 | Correct | 3 ms | 1144 KB | Output is correct |
3 | Correct | 3 ms | 1148 KB | Output is correct |
4 | Correct | 3 ms | 1144 KB | Output is correct |
5 | Correct | 3 ms | 1144 KB | Output is correct |
6 | Correct | 3 ms | 1148 KB | Output is correct |
7 | Correct | 3 ms | 1144 KB | Output is correct |
8 | Correct | 3 ms | 1144 KB | Output is correct |
9 | Correct | 61 ms | 43640 KB | Output is correct |
10 | Correct | 62 ms | 43640 KB | Output is correct |
11 | Correct | 61 ms | 43644 KB | Output is correct |
12 | Correct | 61 ms | 43640 KB | Output is correct |
13 | Correct | 61 ms | 43640 KB | Output is correct |
14 | Correct | 61 ms | 43640 KB | Output is correct |
15 | Correct | 61 ms | 43612 KB | Output is correct |
16 | Correct | 62 ms | 43868 KB | Output is correct |
17 | Correct | 222 ms | 157300 KB | Output is correct |
18 | Correct | 222 ms | 157148 KB | Output is correct |
19 | Correct | 223 ms | 157316 KB | Output is correct |
20 | Correct | 224 ms | 157276 KB | Output is correct |
21 | Correct | 225 ms | 157156 KB | Output is correct |
22 | Correct | 222 ms | 157220 KB | Output is correct |
23 | Correct | 221 ms | 157080 KB | Output is correct |
24 | Correct | 223 ms | 157180 KB | Output is correct |
25 | Correct | 240 ms | 157316 KB | Output is correct |
26 | Correct | 229 ms | 157244 KB | Output is correct |
27 | Correct | 223 ms | 157176 KB | Output is correct |
28 | Correct | 223 ms | 157176 KB | Output is correct |
29 | Correct | 223 ms | 157280 KB | Output is correct |
30 | Correct | 224 ms | 157228 KB | Output is correct |
31 | Correct | 223 ms | 157304 KB | Output is correct |
32 | Correct | 221 ms | 157176 KB | Output is correct |
33 | Correct | 239 ms | 157204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 224 ms | 157296 KB | Output is correct |
2 | Correct | 225 ms | 157336 KB | Output is correct |
3 | Correct | 224 ms | 157228 KB | Output is correct |
4 | Correct | 223 ms | 157176 KB | Output is correct |
5 | Correct | 226 ms | 157176 KB | Output is correct |
6 | Correct | 226 ms | 157300 KB | Output is correct |
7 | Correct | 227 ms | 157276 KB | Output is correct |
8 | Correct | 225 ms | 157304 KB | Output is correct |
9 | Correct | 226 ms | 157304 KB | Output is correct |
10 | Correct | 224 ms | 157176 KB | Output is correct |
11 | Correct | 226 ms | 157304 KB | Output is correct |
12 | Correct | 226 ms | 157220 KB | Output is correct |
13 | Correct | 225 ms | 157160 KB | Output is correct |
14 | Correct | 225 ms | 157308 KB | Output is correct |
15 | Correct | 229 ms | 157176 KB | Output is correct |
16 | Correct | 226 ms | 157176 KB | Output is correct |
17 | Incorrect | 246 ms | 157176 KB | Output isn't correct |
18 | Halted | 0 ms | 0 KB | - |