Submission #1064502

# Submission time Handle Problem Language Result Execution time Memory
1064502 2024-08-18T13:36:03 Z beaconmc Tricks of the Trade (CEOI23_trade) C++14
10 / 100
8000 ms 4232 KB
#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<array<ll,2>> 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

trade.cpp: In function 'int main()':
trade.cpp:30:21: warning: comparison of integer expressions of different signedness: 'std::set<std::array<long long int, 2> >::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::array<long long int, 2> >::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 time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Partially correct 0 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Partially correct 0 ms 348 KB Partially correct
3 Partially correct 1 ms 420 KB Partially correct
4 Partially correct 2 ms 460 KB Partially correct
5 Partially correct 2 ms 348 KB Partially correct
6 Partially correct 1 ms 348 KB Partially correct
7 Partially correct 2 ms 348 KB Partially correct
8 Partially correct 2 ms 344 KB Partially correct
9 Partially correct 1 ms 348 KB Partially correct
10 Partially correct 2 ms 348 KB Partially correct
11 Partially correct 1 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Partially correct 0 ms 348 KB Partially correct
3 Partially correct 1 ms 420 KB Partially correct
4 Partially correct 2 ms 460 KB Partially correct
5 Partially correct 2 ms 348 KB Partially correct
6 Partially correct 1 ms 348 KB Partially correct
7 Partially correct 2 ms 348 KB Partially correct
8 Partially correct 2 ms 344 KB Partially correct
9 Partially correct 1 ms 348 KB Partially correct
10 Partially correct 2 ms 348 KB Partially correct
11 Partially correct 1 ms 348 KB Partially correct
12 Partially correct 0 ms 348 KB Partially correct
13 Partially correct 0 ms 348 KB Partially correct
14 Partially correct 0 ms 404 KB Partially correct
15 Partially correct 2 ms 348 KB Partially correct
16 Partially correct 2 ms 348 KB Partially correct
17 Partially correct 1 ms 348 KB Partially correct
18 Partially correct 2 ms 348 KB Partially correct
19 Partially correct 1 ms 348 KB Partially correct
20 Partially correct 1 ms 452 KB Partially correct
21 Partially correct 3 ms 344 KB Partially correct
22 Partially correct 2 ms 344 KB Partially correct
23 Partially correct 2135 ms 860 KB Partially correct
24 Partially correct 510 ms 344 KB Partially correct
25 Partially correct 1578 ms 600 KB Partially correct
26 Partially correct 1107 ms 348 KB Partially correct
27 Partially correct 1689 ms 604 KB Partially correct
28 Partially correct 477 ms 524 KB Partially correct
29 Partially correct 2168 ms 720 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Execution timed out 8084 ms 4232 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Execution timed out 8084 ms 4232 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Partially correct 0 ms 348 KB Partially correct
3 Partially correct 0 ms 348 KB Partially correct
4 Partially correct 0 ms 348 KB Partially correct
5 Partially correct 1 ms 420 KB Partially correct
6 Partially correct 2 ms 460 KB Partially correct
7 Partially correct 2 ms 348 KB Partially correct
8 Partially correct 1 ms 348 KB Partially correct
9 Partially correct 2 ms 348 KB Partially correct
10 Partially correct 2 ms 344 KB Partially correct
11 Partially correct 1 ms 348 KB Partially correct
12 Partially correct 2 ms 348 KB Partially correct
13 Partially correct 1 ms 348 KB Partially correct
14 Partially correct 0 ms 348 KB Partially correct
15 Partially correct 0 ms 348 KB Partially correct
16 Partially correct 0 ms 404 KB Partially correct
17 Partially correct 2 ms 348 KB Partially correct
18 Partially correct 2 ms 348 KB Partially correct
19 Partially correct 1 ms 348 KB Partially correct
20 Partially correct 2 ms 348 KB Partially correct
21 Partially correct 1 ms 348 KB Partially correct
22 Partially correct 1 ms 452 KB Partially correct
23 Partially correct 3 ms 344 KB Partially correct
24 Partially correct 2 ms 344 KB Partially correct
25 Partially correct 2135 ms 860 KB Partially correct
26 Partially correct 510 ms 344 KB Partially correct
27 Partially correct 1578 ms 600 KB Partially correct
28 Partially correct 1107 ms 348 KB Partially correct
29 Partially correct 1689 ms 604 KB Partially correct
30 Partially correct 477 ms 524 KB Partially correct
31 Partially correct 2168 ms 720 KB Partially correct
32 Partially correct 0 ms 348 KB Partially correct
33 Execution timed out 8084 ms 4232 KB Time limit exceeded
34 Halted 0 ms 0 KB -