| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1064500 | beaconmc | Tricks of the Trade (CEOI23_trade) | C++14 | 8021 ms | 5208 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>
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,k;
cin >> n >> k;
vector<ll> price(n), sell(n);
FOR(i,0,n) cin >> price[i];
FOR(i,0,n) cin >> sell[i];
ll ans = -1000000000000000;
FOR(i,0,n){
set<vector<ll>> stuff;
ll sum = 0;
ll cost = 0;
FOR(j,i,n){
cost += price[j];
sum += sell[j];
stuff.insert({sell[j], j});
if (stuff.size() > k){
auto it = stuff.begin();
sum -= (*it)[0];
stuff.erase(it);
}
if (stuff.size()==k) ans = max(ans, sum-cost);
}
}
cout << ans << "\n";
}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... | ||||
