Submission #1064560

# Submission time Handle Problem Language Result Execution time Memory
1064560 2024-08-18T14:34:28 Z beaconmc Tricks of the Trade (CEOI23_trade) C++14
5 / 100
217 ms 406428 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;


ll dp[250005][205];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	FOR(i,0,250005)FOR(j,0,205) dp[i][j] = -10000000000000000000000;

	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];
	FOR(i,0,250005) dp[i][0] = 0;

	FOR(i,0,n){
		FOR(j,0,205){
			dp[i+1][j] = max(dp[i+1][j], dp[i][j] - price[i]);
			dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] - price[i] + sell[i]);
		}
	}
	ll ans = -10000000000000000000000;


	FOR(i,0,n+1){
	
		ans = max(ans, dp[i][k]);
	}
	cout << ans << endl;







}

Compilation message

trade.cpp:15:42: warning: integer constant is too large for its type
   15 |  FOR(i,0,250005)FOR(j,0,205) dp[i][j] = -10000000000000000000000;
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~
trade.cpp:30:12: warning: integer constant is too large for its type
   30 |  ll ans = -10000000000000000000000;
      |            ^~~~~~~~~~~~~~~~~~~~~~~
trade.cpp: In function 'int main()':
trade.cpp:27:17: warning: iteration 204 invokes undefined behavior [-Waggressive-loop-optimizations]
   27 |    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] - price[i] + sell[i]);
      |    ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
trade.cpp:4:33: note: within this loop
    4 | #define FOR(i,x,y) for(ll i=x; i<y; i++)
......
   25 |   FOR(j,0,205){
      |       ~~~~~~~                    
trade.cpp:25:3: note: in expansion of macro 'FOR'
   25 |   FOR(j,0,205){
      |   ^~~
# Verdict Execution time Memory Grader output
1 Partially correct 126 ms 401416 KB Partially correct
2 Partially correct 127 ms 401496 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 129 ms 401432 KB Partially correct
2 Partially correct 126 ms 401488 KB Partially correct
3 Partially correct 130 ms 401484 KB Partially correct
4 Partially correct 131 ms 401492 KB Partially correct
5 Partially correct 127 ms 401748 KB Partially correct
6 Partially correct 127 ms 401488 KB Partially correct
7 Partially correct 127 ms 401492 KB Partially correct
8 Partially correct 192 ms 401600 KB Partially correct
9 Partially correct 127 ms 401488 KB Partially correct
10 Partially correct 128 ms 401492 KB Partially correct
11 Partially correct 128 ms 401376 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 129 ms 401432 KB Partially correct
2 Partially correct 126 ms 401488 KB Partially correct
3 Partially correct 130 ms 401484 KB Partially correct
4 Partially correct 131 ms 401492 KB Partially correct
5 Partially correct 127 ms 401748 KB Partially correct
6 Partially correct 127 ms 401488 KB Partially correct
7 Partially correct 127 ms 401492 KB Partially correct
8 Partially correct 192 ms 401600 KB Partially correct
9 Partially correct 127 ms 401488 KB Partially correct
10 Partially correct 128 ms 401492 KB Partially correct
11 Partially correct 128 ms 401376 KB Partially correct
12 Partially correct 127 ms 401488 KB Partially correct
13 Partially correct 128 ms 401488 KB Partially correct
14 Partially correct 126 ms 401492 KB Partially correct
15 Partially correct 130 ms 401492 KB Partially correct
16 Partially correct 136 ms 401488 KB Partially correct
17 Partially correct 144 ms 401484 KB Partially correct
18 Partially correct 128 ms 401548 KB Partially correct
19 Partially correct 134 ms 401492 KB Partially correct
20 Partially correct 128 ms 401600 KB Partially correct
21 Partially correct 145 ms 401488 KB Partially correct
22 Partially correct 128 ms 401488 KB Partially correct
23 Incorrect 135 ms 401748 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 133 ms 401488 KB Partially correct
2 Incorrect 217 ms 406428 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 133 ms 401488 KB Partially correct
2 Incorrect 217 ms 406428 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 126 ms 401416 KB Partially correct
2 Partially correct 127 ms 401496 KB Partially correct
3 Partially correct 129 ms 401432 KB Partially correct
4 Partially correct 126 ms 401488 KB Partially correct
5 Partially correct 130 ms 401484 KB Partially correct
6 Partially correct 131 ms 401492 KB Partially correct
7 Partially correct 127 ms 401748 KB Partially correct
8 Partially correct 127 ms 401488 KB Partially correct
9 Partially correct 127 ms 401492 KB Partially correct
10 Partially correct 192 ms 401600 KB Partially correct
11 Partially correct 127 ms 401488 KB Partially correct
12 Partially correct 128 ms 401492 KB Partially correct
13 Partially correct 128 ms 401376 KB Partially correct
14 Partially correct 127 ms 401488 KB Partially correct
15 Partially correct 128 ms 401488 KB Partially correct
16 Partially correct 126 ms 401492 KB Partially correct
17 Partially correct 130 ms 401492 KB Partially correct
18 Partially correct 136 ms 401488 KB Partially correct
19 Partially correct 144 ms 401484 KB Partially correct
20 Partially correct 128 ms 401548 KB Partially correct
21 Partially correct 134 ms 401492 KB Partially correct
22 Partially correct 128 ms 401600 KB Partially correct
23 Partially correct 145 ms 401488 KB Partially correct
24 Partially correct 128 ms 401488 KB Partially correct
25 Incorrect 135 ms 401748 KB Output isn't correct
26 Halted 0 ms 0 KB -