# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1040458 | 2024-08-01T04:37:32 Z | 비요뜨(#11041) | Tricks of the Trade (CEOI23_trade) | C++17 | 8000 ms | 5984 KB |
#include <bits/stdc++.h> using namespace std; int n,k; long long c[250000]; long long s[250000]; typedef pair<long long,int> P; int chk[250000]; int save[250000]; int main() { scanf("%d %d",&n,&k); for(int i=0;i<n;i++) { scanf("%lld",&c[i]); } for(int i=0;i<n;i++) { scanf("%lld",&s[i]); } int l=-1; int r=-1; long long ret=-1e18; for(int i=0;i<n;i++) { priority_queue<long long,vector<long long>,greater<long long>> pq1; long long sum=0; long long ps=0; for(int j=i;j<n;j++) { sum+=c[j]; pq1.push(s[j]); ps+=s[j]; if (pq1.size()>k) { long long one=pq1.top(); pq1.pop(); ps-=one; } if (j-i>=k-1&&ps-sum>ret) { l=i; r=j; ret=ps-sum; } } } printf("%lld\n",ret); int cnt=0; for(int i=0;i<n;i++) { priority_queue<P,vector<P>,greater<P>> pq1; long long sum=0; long long ps=0; for(int j=i;j<n;j++) { sum+=c[j]; pq1.push(P(s[j],j)); save[j]=cnt; ps+=s[j]; if (pq1.size()>k) { P one=pq1.top(); pq1.pop(); ps-=one.first; if (one.second!=j&&save[one.second]<cnt) { chk[one.second]=1; } } if (j-i>=k-1&&ps-sum==ret) { cnt++; } } while (!pq1.empty()) { P one=pq1.top(); pq1.pop(); if (save[one.second]<cnt) { chk[one.second]=1; } } } for(int i=0;i<n;i++) { printf("%d",chk[i]); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 KB | Output is correct |
2 | Correct | 0 ms | 4444 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4444 KB | Output is correct |
2 | Correct | 0 ms | 4444 KB | Output is correct |
3 | Correct | 0 ms | 4444 KB | Output is correct |
4 | Correct | 2 ms | 4444 KB | Output is correct |
5 | Correct | 2 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4548 KB | Output is correct |
7 | Correct | 2 ms | 4440 KB | Output is correct |
8 | Correct | 1 ms | 4444 KB | Output is correct |
9 | Partially correct | 2 ms | 4444 KB | Partially correct |
10 | Correct | 2 ms | 4444 KB | Output is correct |
11 | Partially correct | 2 ms | 4444 KB | Partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4444 KB | Output is correct |
2 | Correct | 0 ms | 4444 KB | Output is correct |
3 | Correct | 0 ms | 4444 KB | Output is correct |
4 | Correct | 2 ms | 4444 KB | Output is correct |
5 | Correct | 2 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4548 KB | Output is correct |
7 | Correct | 2 ms | 4440 KB | Output is correct |
8 | Correct | 1 ms | 4444 KB | Output is correct |
9 | Partially correct | 2 ms | 4444 KB | Partially correct |
10 | Correct | 2 ms | 4444 KB | Output is correct |
11 | Partially correct | 2 ms | 4444 KB | Partially correct |
12 | Correct | 0 ms | 4444 KB | Output is correct |
13 | Correct | 0 ms | 4444 KB | Output is correct |
14 | Correct | 0 ms | 4444 KB | Output is correct |
15 | Correct | 2 ms | 4444 KB | Output is correct |
16 | Correct | 2 ms | 4444 KB | Output is correct |
17 | Correct | 1 ms | 4444 KB | Output is correct |
18 | Correct | 2 ms | 4440 KB | Output is correct |
19 | Correct | 1 ms | 4444 KB | Output is correct |
20 | Partially correct | 1 ms | 4444 KB | Partially correct |
21 | Correct | 2 ms | 4444 KB | Output is correct |
22 | Partially correct | 2 ms | 4444 KB | Partially correct |
23 | Correct | 1807 ms | 4776 KB | Output is correct |
24 | Correct | 402 ms | 4440 KB | Output is correct |
25 | Correct | 1472 ms | 4440 KB | Output is correct |
26 | Correct | 1053 ms | 4440 KB | Output is correct |
27 | Correct | 1131 ms | 4444 KB | Output is correct |
28 | Correct | 389 ms | 4536 KB | Output is correct |
29 | Correct | 1760 ms | 4440 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Execution timed out | 8090 ms | 5984 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Execution timed out | 8090 ms | 5984 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 KB | Output is correct |
2 | Correct | 0 ms | 4444 KB | Output is correct |
3 | Correct | 0 ms | 4444 KB | Output is correct |
4 | Correct | 0 ms | 4444 KB | Output is correct |
5 | Correct | 0 ms | 4444 KB | Output is correct |
6 | Correct | 2 ms | 4444 KB | Output is correct |
7 | Correct | 2 ms | 4444 KB | Output is correct |
8 | Correct | 1 ms | 4548 KB | Output is correct |
9 | Correct | 2 ms | 4440 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Partially correct | 2 ms | 4444 KB | Partially correct |
12 | Correct | 2 ms | 4444 KB | Output is correct |
13 | Partially correct | 2 ms | 4444 KB | Partially correct |
14 | Correct | 0 ms | 4444 KB | Output is correct |
15 | Correct | 0 ms | 4444 KB | Output is correct |
16 | Correct | 0 ms | 4444 KB | Output is correct |
17 | Correct | 2 ms | 4444 KB | Output is correct |
18 | Correct | 2 ms | 4444 KB | Output is correct |
19 | Correct | 1 ms | 4444 KB | Output is correct |
20 | Correct | 2 ms | 4440 KB | Output is correct |
21 | Correct | 1 ms | 4444 KB | Output is correct |
22 | Partially correct | 1 ms | 4444 KB | Partially correct |
23 | Correct | 2 ms | 4444 KB | Output is correct |
24 | Partially correct | 2 ms | 4444 KB | Partially correct |
25 | Correct | 1807 ms | 4776 KB | Output is correct |
26 | Correct | 402 ms | 4440 KB | Output is correct |
27 | Correct | 1472 ms | 4440 KB | Output is correct |
28 | Correct | 1053 ms | 4440 KB | Output is correct |
29 | Correct | 1131 ms | 4444 KB | Output is correct |
30 | Correct | 389 ms | 4536 KB | Output is correct |
31 | Correct | 1760 ms | 4440 KB | Output is correct |
32 | Correct | 1 ms | 4440 KB | Output is correct |
33 | Execution timed out | 8090 ms | 5984 KB | Time limit exceeded |
34 | Halted | 0 ms | 0 KB | - |