Submission #1064500

#TimeUsernameProblemLanguageResultExecution timeMemory
1064500beaconmcTricks of the Trade (CEOI23_trade)C++14
10 / 100
8021 ms5208 KiB
#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)

trade.cpp: In function 'int main()':
trade.cpp:30:21: warning: comparison of integer expressions of different signedness: 'std::set<std::vector<long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   30 |    if (stuff.size() > k){
      |        ~~~~~~~~~~~~~^~~
trade.cpp:36:20: warning: comparison of integer expressions of different signedness: 'std::set<std::vector<long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   36 |    if (stuff.size()==k) ans = max(ans, sum-cost);
      |        ~~~~~~~~~~~~^~~
#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...