# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1071833 | edogawa_something | Tricks of the Trade (CEOI23_trade) | C++17 | 0 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
ll n,k,a[M],b[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=0;
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[i];
if(q.size()<k)
q.push(b[i]),psum+=b[i];
else {
if(b[i]<q.top())
continue;
else
psum-=q.top(),q.pop(),q.push(b[i]),psum+=b[i];
}
ans=max(ans,psum-nsum);
}
}
cout<<ans<<'\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |