# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1071875 | 2024-08-23T12:02:39 Z | edogawa_something | Tricks of the Trade (CEOI23_trade) | C++17 | 1008 ms | 172924 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vii; typedef pair<ll,ll> pii; #define F first #define S second #define all(v) v.begin(),v.end() #define pb push_back const ll M=6e3+10; const ll inf=2e18; ll n,k,a[M],b[M],c[M]; vii psh[M],pp[M]; int main() { ios_base::sync_with_stdio(0),cin.tie(0); cin>>n>>k; for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<n;i++) cin>>b[i]; ll ans=-inf; ll l,r; for(int i=0;i<n;i++) { ll nsum=0,psum=0; priority_queue<ll,vii,greater<ll>>q; for(int j=i;j<n;j++) { nsum+=a[j]; if(q.size()<k) q.push(b[j]),psum+=b[j]; else { if(b[j]<q.top()) continue; else psum-=q.top(),q.pop(),q.push(b[j]),psum+=b[j]; } if(q.size()==k) { if(ans<psum-nsum) { ans=max(ans,psum-nsum); l=i,r=j; } } } } cout<<ans<<'\n'; for(int i=0;i<n;i++) { ll nsum=0,psum=0; priority_queue<ll,vii,greater<ll>>q; for(int j=i;j<n;j++) { nsum+=a[j]; if(q.size()<k) q.push(b[j]),psum+=b[j]; else { if(b[j]<q.top()) continue; else psum-=q.top(),q.pop(),q.push(b[j]),psum+=b[j]; } if(q.size()==k) { if(ans==psum-nsum) { psh[i].pb(q.top()); pp[j].pb(q.top()); } } } } multiset<ll>s; for(int i=0;i<n;i++) { for(auto it:psh[i]) s.insert(it); if(s.size()>0&&b[i]>=*s.begin()) cout<<1; else cout<<0; for(auto it:pp[i]) s.erase(s.find(it)); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 604 KB | Output is correct |
2 | Correct | 0 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 604 KB | Output is correct |
2 | Correct | 0 ms | 604 KB | Output is correct |
3 | Correct | 0 ms | 604 KB | Output is correct |
4 | Correct | 1 ms | 604 KB | Output is correct |
5 | Correct | 1 ms | 604 KB | Output is correct |
6 | Correct | 0 ms | 604 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 1 ms | 860 KB | Output is correct |
9 | Correct | 1 ms | 604 KB | Output is correct |
10 | Correct | 1 ms | 604 KB | Output is correct |
11 | Correct | 1 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 604 KB | Output is correct |
2 | Correct | 0 ms | 604 KB | Output is correct |
3 | Correct | 0 ms | 604 KB | Output is correct |
4 | Correct | 1 ms | 604 KB | Output is correct |
5 | Correct | 1 ms | 604 KB | Output is correct |
6 | Correct | 0 ms | 604 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 1 ms | 860 KB | Output is correct |
9 | Correct | 1 ms | 604 KB | Output is correct |
10 | Correct | 1 ms | 604 KB | Output is correct |
11 | Correct | 1 ms | 604 KB | Output is correct |
12 | Correct | 1 ms | 600 KB | Output is correct |
13 | Correct | 1 ms | 604 KB | Output is correct |
14 | Correct | 1 ms | 604 KB | Output is correct |
15 | Correct | 1 ms | 604 KB | Output is correct |
16 | Correct | 1 ms | 604 KB | Output is correct |
17 | Correct | 1 ms | 604 KB | Output is correct |
18 | Correct | 1 ms | 604 KB | Output is correct |
19 | Correct | 1 ms | 860 KB | Output is correct |
20 | Correct | 1 ms | 604 KB | Output is correct |
21 | Correct | 1 ms | 604 KB | Output is correct |
22 | Correct | 1 ms | 604 KB | Output is correct |
23 | Correct | 582 ms | 928 KB | Output is correct |
24 | Correct | 99 ms | 852 KB | Output is correct |
25 | Correct | 1008 ms | 1084 KB | Output is correct |
26 | Correct | 730 ms | 820 KB | Output is correct |
27 | Correct | 982 ms | 172924 KB | Output is correct |
28 | Correct | 47 ms | 600 KB | Output is correct |
29 | Correct | 932 ms | 1104 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 604 KB | Output is correct |
2 | Incorrect | 1 ms | 604 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 604 KB | Output is correct |
2 | Incorrect | 1 ms | 604 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 604 KB | Output is correct |
2 | Correct | 0 ms | 604 KB | Output is correct |
3 | Correct | 0 ms | 604 KB | Output is correct |
4 | Correct | 0 ms | 604 KB | Output is correct |
5 | Correct | 0 ms | 604 KB | Output is correct |
6 | Correct | 1 ms | 604 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 0 ms | 604 KB | Output is correct |
9 | Correct | 1 ms | 604 KB | Output is correct |
10 | Correct | 1 ms | 860 KB | Output is correct |
11 | Correct | 1 ms | 604 KB | Output is correct |
12 | Correct | 1 ms | 604 KB | Output is correct |
13 | Correct | 1 ms | 604 KB | Output is correct |
14 | Correct | 1 ms | 600 KB | Output is correct |
15 | Correct | 1 ms | 604 KB | Output is correct |
16 | Correct | 1 ms | 604 KB | Output is correct |
17 | Correct | 1 ms | 604 KB | Output is correct |
18 | Correct | 1 ms | 604 KB | Output is correct |
19 | Correct | 1 ms | 604 KB | Output is correct |
20 | Correct | 1 ms | 604 KB | Output is correct |
21 | Correct | 1 ms | 860 KB | Output is correct |
22 | Correct | 1 ms | 604 KB | Output is correct |
23 | Correct | 1 ms | 604 KB | Output is correct |
24 | Correct | 1 ms | 604 KB | Output is correct |
25 | Correct | 582 ms | 928 KB | Output is correct |
26 | Correct | 99 ms | 852 KB | Output is correct |
27 | Correct | 1008 ms | 1084 KB | Output is correct |
28 | Correct | 730 ms | 820 KB | Output is correct |
29 | Correct | 982 ms | 172924 KB | Output is correct |
30 | Correct | 47 ms | 600 KB | Output is correct |
31 | Correct | 932 ms | 1104 KB | Output is correct |
32 | Correct | 1 ms | 604 KB | Output is correct |
33 | Incorrect | 1 ms | 604 KB | Output isn't correct |
34 | Halted | 0 ms | 0 KB | - |