# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1089880 | 2024-09-17T11:00:41 Z | KALARRY | Tricks of the Trade (CEOI23_trade) | C++14 | 1480 ms | 2097152 KB |
//chockolateman #include<bits/stdc++.h> using namespace std; long long N,K,a[250005],b[250005],dp[250005][205]; vector<pair<int,int>> adj[250005][205]; bool visited[250005][205]; bool used[250005]; void dfs(int v,int j) { if(visited[v][j]) return; visited[v][j] = true; if(j==0) return; for(auto e : adj[v][j]) { int u = e.first; int newj = e.second; if(newj==(j-1)) used[v] = true; dfs(u,newj); } } int main() { scanf("%lld%lld",&N,&K); for(long long i = 1 ; i <= N ; i++) scanf("%lld",&a[i]); for(long long i = 1 ; i <= N ; i++) scanf("%lld",&b[i]); for(long long j = 1 ; j <= K ; j++) { dp[0][j%2] = -1e15; for(long long i = 1 ; i <= N ; i++) { dp[i][j%2] = max(dp[i-1][j%2] - a[i],dp[i-1][(j-1)%2] + b[i] - a[i]); if(dp[i][j%2]==dp[i-1][j%2] - a[i]) adj[i][j].push_back({i-1,j}); if(dp[i][j%2] == dp[i-1][(j-1)%2] + b[i] - a[i]) adj[i][j].push_back({i-1,j-1}); } } long long ans = -1e15; for(long long i = 1 ; i <= N ; i++) ans = max(ans,dp[i][K%2]); for(long long i = 1 ; i <= N ; i++) if(dp[i][K%2]==ans) dfs(i,K); printf("%lld\n",ans); for(int i = 1 ; i <= N ; i++) printf("%d",used[i]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 465 ms | 1204012 KB | Output is correct |
2 | Correct | 476 ms | 1203820 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 469 ms | 1203792 KB | Output is correct |
2 | Correct | 455 ms | 1203792 KB | Output is correct |
3 | Correct | 452 ms | 1203884 KB | Output is correct |
4 | Correct | 520 ms | 1204856 KB | Output is correct |
5 | Correct | 469 ms | 1205444 KB | Output is correct |
6 | Correct | 461 ms | 1204304 KB | Output is correct |
7 | Correct | 467 ms | 1204524 KB | Output is correct |
8 | Correct | 476 ms | 1204816 KB | Output is correct |
9 | Correct | 485 ms | 1205016 KB | Output is correct |
10 | Correct | 471 ms | 1204564 KB | Output is correct |
11 | Correct | 480 ms | 1204564 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 469 ms | 1203792 KB | Output is correct |
2 | Correct | 455 ms | 1203792 KB | Output is correct |
3 | Correct | 452 ms | 1203884 KB | Output is correct |
4 | Correct | 520 ms | 1204856 KB | Output is correct |
5 | Correct | 469 ms | 1205444 KB | Output is correct |
6 | Correct | 461 ms | 1204304 KB | Output is correct |
7 | Correct | 467 ms | 1204524 KB | Output is correct |
8 | Correct | 476 ms | 1204816 KB | Output is correct |
9 | Correct | 485 ms | 1205016 KB | Output is correct |
10 | Correct | 471 ms | 1204564 KB | Output is correct |
11 | Correct | 480 ms | 1204564 KB | Output is correct |
12 | Correct | 462 ms | 1204004 KB | Output is correct |
13 | Correct | 444 ms | 1203792 KB | Output is correct |
14 | Correct | 453 ms | 1204188 KB | Output is correct |
15 | Correct | 470 ms | 1204820 KB | Output is correct |
16 | Correct | 461 ms | 1205588 KB | Output is correct |
17 | Correct | 420 ms | 1204308 KB | Output is correct |
18 | Correct | 416 ms | 1204560 KB | Output is correct |
19 | Correct | 426 ms | 1204820 KB | Output is correct |
20 | Correct | 444 ms | 1204544 KB | Output is correct |
21 | Correct | 460 ms | 1204552 KB | Output is correct |
22 | Correct | 458 ms | 1204564 KB | Output is correct |
23 | Partially correct | 1480 ms | 1551100 KB | Partially correct |
24 | Correct | 477 ms | 1215568 KB | Output is correct |
25 | Partially correct | 843 ms | 1306816 KB | Partially correct |
26 | Correct | 511 ms | 1233752 KB | Output is correct |
27 | Partially correct | 1249 ms | 1483348 KB | Partially correct |
28 | Correct | 483 ms | 1214000 KB | Output is correct |
29 | Partially correct | 1123 ms | 1387856 KB | Partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 481 ms | 1203992 KB | Output is correct |
2 | Correct | 701 ms | 1676208 KB | Output is correct |
3 | Correct | 691 ms | 1627984 KB | Output is correct |
4 | Correct | 677 ms | 1627908 KB | Output is correct |
5 | Correct | 726 ms | 1679416 KB | Output is correct |
6 | Correct | 707 ms | 1677904 KB | Output is correct |
7 | Correct | 718 ms | 1689172 KB | Output is correct |
8 | Correct | 677 ms | 1627988 KB | Output is correct |
9 | Correct | 742 ms | 1626452 KB | Output is correct |
10 | Correct | 733 ms | 1677408 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 481 ms | 1203992 KB | Output is correct |
2 | Correct | 701 ms | 1676208 KB | Output is correct |
3 | Correct | 691 ms | 1627984 KB | Output is correct |
4 | Correct | 677 ms | 1627908 KB | Output is correct |
5 | Correct | 726 ms | 1679416 KB | Output is correct |
6 | Correct | 707 ms | 1677904 KB | Output is correct |
7 | Correct | 718 ms | 1689172 KB | Output is correct |
8 | Correct | 677 ms | 1627988 KB | Output is correct |
9 | Correct | 742 ms | 1626452 KB | Output is correct |
10 | Correct | 733 ms | 1677408 KB | Output is correct |
11 | Correct | 469 ms | 1204000 KB | Output is correct |
12 | Correct | 714 ms | 1676112 KB | Output is correct |
13 | Correct | 695 ms | 1627988 KB | Output is correct |
14 | Correct | 663 ms | 1627992 KB | Output is correct |
15 | Correct | 778 ms | 1679444 KB | Output is correct |
16 | Correct | 737 ms | 1677832 KB | Output is correct |
17 | Correct | 888 ms | 1689084 KB | Output is correct |
18 | Correct | 693 ms | 1627816 KB | Output is correct |
19 | Correct | 689 ms | 1626460 KB | Output is correct |
20 | Correct | 735 ms | 1677376 KB | Output is correct |
21 | Correct | 431 ms | 1203796 KB | Output is correct |
22 | Correct | 421 ms | 1203796 KB | Output is correct |
23 | Correct | 423 ms | 1204816 KB | Output is correct |
24 | Correct | 422 ms | 1205588 KB | Output is correct |
25 | Correct | 426 ms | 1204308 KB | Output is correct |
26 | Correct | 450 ms | 1204472 KB | Output is correct |
27 | Correct | 463 ms | 1204740 KB | Output is correct |
28 | Correct | 471 ms | 1204744 KB | Output is correct |
29 | Correct | 467 ms | 1204584 KB | Output is correct |
30 | Correct | 461 ms | 1204604 KB | Output is correct |
31 | Runtime error | 1181 ms | 2097152 KB | Execution killed with signal 9 |
32 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 465 ms | 1204012 KB | Output is correct |
2 | Correct | 476 ms | 1203820 KB | Output is correct |
3 | Correct | 469 ms | 1203792 KB | Output is correct |
4 | Correct | 455 ms | 1203792 KB | Output is correct |
5 | Correct | 452 ms | 1203884 KB | Output is correct |
6 | Correct | 520 ms | 1204856 KB | Output is correct |
7 | Correct | 469 ms | 1205444 KB | Output is correct |
8 | Correct | 461 ms | 1204304 KB | Output is correct |
9 | Correct | 467 ms | 1204524 KB | Output is correct |
10 | Correct | 476 ms | 1204816 KB | Output is correct |
11 | Correct | 485 ms | 1205016 KB | Output is correct |
12 | Correct | 471 ms | 1204564 KB | Output is correct |
13 | Correct | 480 ms | 1204564 KB | Output is correct |
14 | Correct | 462 ms | 1204004 KB | Output is correct |
15 | Correct | 444 ms | 1203792 KB | Output is correct |
16 | Correct | 453 ms | 1204188 KB | Output is correct |
17 | Correct | 470 ms | 1204820 KB | Output is correct |
18 | Correct | 461 ms | 1205588 KB | Output is correct |
19 | Correct | 420 ms | 1204308 KB | Output is correct |
20 | Correct | 416 ms | 1204560 KB | Output is correct |
21 | Correct | 426 ms | 1204820 KB | Output is correct |
22 | Correct | 444 ms | 1204544 KB | Output is correct |
23 | Correct | 460 ms | 1204552 KB | Output is correct |
24 | Correct | 458 ms | 1204564 KB | Output is correct |
25 | Partially correct | 1480 ms | 1551100 KB | Partially correct |
26 | Correct | 477 ms | 1215568 KB | Output is correct |
27 | Partially correct | 843 ms | 1306816 KB | Partially correct |
28 | Correct | 511 ms | 1233752 KB | Output is correct |
29 | Partially correct | 1249 ms | 1483348 KB | Partially correct |
30 | Correct | 483 ms | 1214000 KB | Output is correct |
31 | Partially correct | 1123 ms | 1387856 KB | Partially correct |
32 | Correct | 481 ms | 1203992 KB | Output is correct |
33 | Correct | 701 ms | 1676208 KB | Output is correct |
34 | Correct | 691 ms | 1627984 KB | Output is correct |
35 | Correct | 677 ms | 1627908 KB | Output is correct |
36 | Correct | 726 ms | 1679416 KB | Output is correct |
37 | Correct | 707 ms | 1677904 KB | Output is correct |
38 | Correct | 718 ms | 1689172 KB | Output is correct |
39 | Correct | 677 ms | 1627988 KB | Output is correct |
40 | Correct | 742 ms | 1626452 KB | Output is correct |
41 | Correct | 733 ms | 1677408 KB | Output is correct |
42 | Correct | 469 ms | 1204000 KB | Output is correct |
43 | Correct | 714 ms | 1676112 KB | Output is correct |
44 | Correct | 695 ms | 1627988 KB | Output is correct |
45 | Correct | 663 ms | 1627992 KB | Output is correct |
46 | Correct | 778 ms | 1679444 KB | Output is correct |
47 | Correct | 737 ms | 1677832 KB | Output is correct |
48 | Correct | 888 ms | 1689084 KB | Output is correct |
49 | Correct | 693 ms | 1627816 KB | Output is correct |
50 | Correct | 689 ms | 1626460 KB | Output is correct |
51 | Correct | 735 ms | 1677376 KB | Output is correct |
52 | Correct | 431 ms | 1203796 KB | Output is correct |
53 | Correct | 421 ms | 1203796 KB | Output is correct |
54 | Correct | 423 ms | 1204816 KB | Output is correct |
55 | Correct | 422 ms | 1205588 KB | Output is correct |
56 | Correct | 426 ms | 1204308 KB | Output is correct |
57 | Correct | 450 ms | 1204472 KB | Output is correct |
58 | Correct | 463 ms | 1204740 KB | Output is correct |
59 | Correct | 471 ms | 1204744 KB | Output is correct |
60 | Correct | 467 ms | 1204584 KB | Output is correct |
61 | Correct | 461 ms | 1204604 KB | Output is correct |
62 | Runtime error | 1181 ms | 2097152 KB | Execution killed with signal 9 |
63 | Halted | 0 ms | 0 KB | - |