# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1040740 | 2024-08-01T08:52:05 Z | 정희우(#10998) | Tricks of the Trade (CEOI23_trade) | C++17 | 8000 ms | 3540 KB |
#include<iostream> #include<algorithm> #include<vector> #include<queue> using namespace std; using lint = long long; using intp = pair<int,int>; using vint = vector<int>; const int MAX_N=250010; const int MAX_K=6010; const lint INF=1e+9*MAX_N; int n,k; int c[MAX_N],p[MAX_N]; priority_queue<int,vint,greater<int>> pq; lint lv[MAX_K],rv[MAX_K]; lint ans; int possi[MAX_N]; void calc(int s,int e) { if(e-s<k)return; int m=(s+e)>>1; fill(lv,lv+MAX_K,-INF); fill(rv,rv+MAX_K,-INF); lv[0]=rv[0]=0; for(int i=1;i<=k;i++) { lint cnt=0; for(int j=m-1;j>=s;j--) { cnt+=p[j]-c[j]; pq.push(p[j]); while(!pq.empty() && pq.size()>i) { cnt-=pq.top(); pq.pop(); } if(!pq.empty() && pq.size()==i) lv[i]=max(lv[i],cnt); } while(!pq.empty())pq.pop(); cnt=0; for(int j=m;j<e;j++) { cnt+=p[j]-c[j]; pq.push(p[j]); while(!pq.empty() && pq.size()>i) { cnt-=pq.top(); pq.pop(); } if(!pq.empty() && pq.size()==i) rv[i]=max(rv[i],cnt); } while(!pq.empty())pq.pop(); } for(int i=0;i<=k;i++) ans=max(ans,lv[i]+rv[k-i]); calc(s,m); calc(m,e); } int main() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); cin >> n >> k; for(int i=0;i<n;i++) cin >> c[i]; for(int i=0;i<n;i++) cin >> p[i]; ans=-INF; calc(0,n); cout << ans << '\n'; for(int i=0;i<n;i++) cout << possi[i]; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 1 ms | 2396 KB | Partially correct |
2 | Partially correct | 0 ms | 2396 KB | Partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 0 ms | 2396 KB | Partially correct |
2 | Partially correct | 1 ms | 2396 KB | Partially correct |
3 | Partially correct | 0 ms | 2396 KB | Partially correct |
4 | Partially correct | 1 ms | 2396 KB | Partially correct |
5 | Partially correct | 1 ms | 2396 KB | Partially correct |
6 | Partially correct | 1 ms | 2396 KB | Partially correct |
7 | Partially correct | 1 ms | 2396 KB | Partially correct |
8 | Partially correct | 1 ms | 2396 KB | Partially correct |
9 | Partially correct | 1 ms | 2396 KB | Partially correct |
10 | Partially correct | 1 ms | 2396 KB | Partially correct |
11 | Partially correct | 1 ms | 2396 KB | Partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 0 ms | 2396 KB | Partially correct |
2 | Partially correct | 1 ms | 2396 KB | Partially correct |
3 | Partially correct | 0 ms | 2396 KB | Partially correct |
4 | Partially correct | 1 ms | 2396 KB | Partially correct |
5 | Partially correct | 1 ms | 2396 KB | Partially correct |
6 | Partially correct | 1 ms | 2396 KB | Partially correct |
7 | Partially correct | 1 ms | 2396 KB | Partially correct |
8 | Partially correct | 1 ms | 2396 KB | Partially correct |
9 | Partially correct | 1 ms | 2396 KB | Partially correct |
10 | Partially correct | 1 ms | 2396 KB | Partially correct |
11 | Partially correct | 1 ms | 2396 KB | Partially correct |
12 | Partially correct | 1 ms | 2392 KB | Partially correct |
13 | Partially correct | 1 ms | 2396 KB | Partially correct |
14 | Partially correct | 1 ms | 2396 KB | Partially correct |
15 | Partially correct | 1 ms | 2396 KB | Partially correct |
16 | Partially correct | 1 ms | 2396 KB | Partially correct |
17 | Partially correct | 1 ms | 2396 KB | Partially correct |
18 | Partially correct | 1 ms | 2396 KB | Partially correct |
19 | Partially correct | 1 ms | 2396 KB | Partially correct |
20 | Partially correct | 1 ms | 2396 KB | Partially correct |
21 | Partially correct | 1 ms | 2396 KB | Partially correct |
22 | Partially correct | 1 ms | 2396 KB | Partially correct |
23 | Partially correct | 1820 ms | 2524 KB | Partially correct |
24 | Partially correct | 25 ms | 2392 KB | Partially correct |
25 | Partially correct | 614 ms | 2500 KB | Partially correct |
26 | Partially correct | 80 ms | 2396 KB | Partially correct |
27 | Partially correct | 419 ms | 2528 KB | Partially correct |
28 | Partially correct | 32 ms | 2396 KB | Partially correct |
29 | Partially correct | 1645 ms | 2524 KB | Partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 1 ms | 2396 KB | Partially correct |
2 | Partially correct | 1508 ms | 3540 KB | Partially correct |
3 | Partially correct | 1445 ms | 3540 KB | Partially correct |
4 | Partially correct | 1351 ms | 3296 KB | Partially correct |
5 | Partially correct | 1346 ms | 3540 KB | Partially correct |
6 | Partially correct | 1425 ms | 3536 KB | Partially correct |
7 | Partially correct | 1434 ms | 3540 KB | Partially correct |
8 | Partially correct | 1377 ms | 3296 KB | Partially correct |
9 | Partially correct | 1367 ms | 3540 KB | Partially correct |
10 | Partially correct | 1377 ms | 3540 KB | Partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 1 ms | 2396 KB | Partially correct |
2 | Partially correct | 1508 ms | 3540 KB | Partially correct |
3 | Partially correct | 1445 ms | 3540 KB | Partially correct |
4 | Partially correct | 1351 ms | 3296 KB | Partially correct |
5 | Partially correct | 1346 ms | 3540 KB | Partially correct |
6 | Partially correct | 1425 ms | 3536 KB | Partially correct |
7 | Partially correct | 1434 ms | 3540 KB | Partially correct |
8 | Partially correct | 1377 ms | 3296 KB | Partially correct |
9 | Partially correct | 1367 ms | 3540 KB | Partially correct |
10 | Partially correct | 1377 ms | 3540 KB | Partially correct |
11 | Partially correct | 1 ms | 2396 KB | Partially correct |
12 | Partially correct | 1351 ms | 3536 KB | Partially correct |
13 | Partially correct | 1361 ms | 3536 KB | Partially correct |
14 | Partially correct | 1366 ms | 3408 KB | Partially correct |
15 | Partially correct | 1394 ms | 3540 KB | Partially correct |
16 | Partially correct | 1348 ms | 3536 KB | Partially correct |
17 | Partially correct | 1353 ms | 3536 KB | Partially correct |
18 | Partially correct | 1383 ms | 3412 KB | Partially correct |
19 | Partially correct | 1350 ms | 3408 KB | Partially correct |
20 | Partially correct | 1362 ms | 3300 KB | Partially correct |
21 | Partially correct | 0 ms | 2396 KB | Partially correct |
22 | Partially correct | 0 ms | 2396 KB | Partially correct |
23 | Partially correct | 1 ms | 2396 KB | Partially correct |
24 | Partially correct | 1 ms | 2396 KB | Partially correct |
25 | Partially correct | 1 ms | 2396 KB | Partially correct |
26 | Partially correct | 1 ms | 2392 KB | Partially correct |
27 | Partially correct | 1 ms | 2396 KB | Partially correct |
28 | Partially correct | 1 ms | 2396 KB | Partially correct |
29 | Partially correct | 1 ms | 2392 KB | Partially correct |
30 | Partially correct | 1 ms | 2396 KB | Partially correct |
31 | Execution timed out | 8060 ms | 3284 KB | Time limit exceeded |
32 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 1 ms | 2396 KB | Partially correct |
2 | Partially correct | 0 ms | 2396 KB | Partially correct |
3 | Partially correct | 0 ms | 2396 KB | Partially correct |
4 | Partially correct | 1 ms | 2396 KB | Partially correct |
5 | Partially correct | 0 ms | 2396 KB | Partially correct |
6 | Partially correct | 1 ms | 2396 KB | Partially correct |
7 | Partially correct | 1 ms | 2396 KB | Partially correct |
8 | Partially correct | 1 ms | 2396 KB | Partially correct |
9 | Partially correct | 1 ms | 2396 KB | Partially correct |
10 | Partially correct | 1 ms | 2396 KB | Partially correct |
11 | Partially correct | 1 ms | 2396 KB | Partially correct |
12 | Partially correct | 1 ms | 2396 KB | Partially correct |
13 | Partially correct | 1 ms | 2396 KB | Partially correct |
14 | Partially correct | 1 ms | 2392 KB | Partially correct |
15 | Partially correct | 1 ms | 2396 KB | Partially correct |
16 | Partially correct | 1 ms | 2396 KB | Partially correct |
17 | Partially correct | 1 ms | 2396 KB | Partially correct |
18 | Partially correct | 1 ms | 2396 KB | Partially correct |
19 | Partially correct | 1 ms | 2396 KB | Partially correct |
20 | Partially correct | 1 ms | 2396 KB | Partially correct |
21 | Partially correct | 1 ms | 2396 KB | Partially correct |
22 | Partially correct | 1 ms | 2396 KB | Partially correct |
23 | Partially correct | 1 ms | 2396 KB | Partially correct |
24 | Partially correct | 1 ms | 2396 KB | Partially correct |
25 | Partially correct | 1820 ms | 2524 KB | Partially correct |
26 | Partially correct | 25 ms | 2392 KB | Partially correct |
27 | Partially correct | 614 ms | 2500 KB | Partially correct |
28 | Partially correct | 80 ms | 2396 KB | Partially correct |
29 | Partially correct | 419 ms | 2528 KB | Partially correct |
30 | Partially correct | 32 ms | 2396 KB | Partially correct |
31 | Partially correct | 1645 ms | 2524 KB | Partially correct |
32 | Partially correct | 1 ms | 2396 KB | Partially correct |
33 | Partially correct | 1508 ms | 3540 KB | Partially correct |
34 | Partially correct | 1445 ms | 3540 KB | Partially correct |
35 | Partially correct | 1351 ms | 3296 KB | Partially correct |
36 | Partially correct | 1346 ms | 3540 KB | Partially correct |
37 | Partially correct | 1425 ms | 3536 KB | Partially correct |
38 | Partially correct | 1434 ms | 3540 KB | Partially correct |
39 | Partially correct | 1377 ms | 3296 KB | Partially correct |
40 | Partially correct | 1367 ms | 3540 KB | Partially correct |
41 | Partially correct | 1377 ms | 3540 KB | Partially correct |
42 | Partially correct | 1 ms | 2396 KB | Partially correct |
43 | Partially correct | 1351 ms | 3536 KB | Partially correct |
44 | Partially correct | 1361 ms | 3536 KB | Partially correct |
45 | Partially correct | 1366 ms | 3408 KB | Partially correct |
46 | Partially correct | 1394 ms | 3540 KB | Partially correct |
47 | Partially correct | 1348 ms | 3536 KB | Partially correct |
48 | Partially correct | 1353 ms | 3536 KB | Partially correct |
49 | Partially correct | 1383 ms | 3412 KB | Partially correct |
50 | Partially correct | 1350 ms | 3408 KB | Partially correct |
51 | Partially correct | 1362 ms | 3300 KB | Partially correct |
52 | Partially correct | 0 ms | 2396 KB | Partially correct |
53 | Partially correct | 0 ms | 2396 KB | Partially correct |
54 | Partially correct | 1 ms | 2396 KB | Partially correct |
55 | Partially correct | 1 ms | 2396 KB | Partially correct |
56 | Partially correct | 1 ms | 2396 KB | Partially correct |
57 | Partially correct | 1 ms | 2392 KB | Partially correct |
58 | Partially correct | 1 ms | 2396 KB | Partially correct |
59 | Partially correct | 1 ms | 2396 KB | Partially correct |
60 | Partially correct | 1 ms | 2392 KB | Partially correct |
61 | Partially correct | 1 ms | 2396 KB | Partially correct |
62 | Execution timed out | 8060 ms | 3284 KB | Time limit exceeded |
63 | Halted | 0 ms | 0 KB | - |