Submission #1071833

#TimeUsernameProblemLanguageResultExecution timeMemory
1071833edogawa_somethingTricks of the Trade (CEOI23_trade)C++17
0 / 100
0 ms348 KiB
#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)

trade.cpp: In function 'int main()':
trade.cpp:25:24: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   25 |             if(q.size()<k)
      |                ~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...