답안 #1064593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1064593 2024-08-18T15:09:05 Z beaconmc Tricks of the Trade (CEOI23_trade) C++14
20 / 100
847 ms 457876 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];
bool visited[250005][205];

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

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


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


	ll ans = -100000000000000000;

	FOR(i,k,n+1){
		ans = max(ans, dp[i][k]);
	}
	FOR(i,k,n+1){
		if (dp[i][k]==ans) visited[i][k] = 1;
	}

	vector<ll> used(n);

	FORNEG(j,203,-1){
		FORNEG(i,n-1,-1){
			if (dp[i+1][j+1] == dp[i][j] + sell[i] - price[i]&& visited[i+1][j+1]){
				visited[i][j] = 1;
				used[i]=1;
			}
			if (dp[i+1][j+1] == dp[i][j+1] - price[i]){
				visited[i][j+1] = 1;
			}
		}
	}




	cout << ans << endl;
	FOR(i,0,n) cout << used[i];







}
# 결과 실행 시간 메모리 Grader output
1 Correct 152 ms 451536 KB Output is correct
2 Correct 161 ms 451664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 153 ms 451648 KB Output is correct
2 Correct 174 ms 451740 KB Output is correct
3 Correct 153 ms 451668 KB Output is correct
4 Partially correct 163 ms 451624 KB Partially correct
5 Correct 175 ms 451552 KB Output is correct
6 Partially correct 165 ms 451704 KB Partially correct
7 Partially correct 254 ms 451672 KB Partially correct
8 Correct 150 ms 451668 KB Output is correct
9 Partially correct 154 ms 451588 KB Partially correct
10 Partially correct 161 ms 451664 KB Partially correct
11 Partially correct 150 ms 451576 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 153 ms 451648 KB Output is correct
2 Correct 174 ms 451740 KB Output is correct
3 Correct 153 ms 451668 KB Output is correct
4 Partially correct 163 ms 451624 KB Partially correct
5 Correct 175 ms 451552 KB Output is correct
6 Partially correct 165 ms 451704 KB Partially correct
7 Partially correct 254 ms 451672 KB Partially correct
8 Correct 150 ms 451668 KB Output is correct
9 Partially correct 154 ms 451588 KB Partially correct
10 Partially correct 161 ms 451664 KB Partially correct
11 Partially correct 150 ms 451576 KB Partially correct
12 Correct 157 ms 451668 KB Output is correct
13 Correct 162 ms 451620 KB Output is correct
14 Correct 165 ms 451664 KB Output is correct
15 Partially correct 151 ms 451668 KB Partially correct
16 Correct 164 ms 451668 KB Output is correct
17 Partially correct 167 ms 451664 KB Partially correct
18 Partially correct 159 ms 451668 KB Partially correct
19 Correct 159 ms 451664 KB Output is correct
20 Partially correct 158 ms 451664 KB Partially correct
21 Partially correct 163 ms 451664 KB Partially correct
22 Partially correct 163 ms 451668 KB Partially correct
23 Incorrect 175 ms 451668 KB Output isn't correct
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 164 ms 451668 KB Output is correct
2 Partially correct 768 ms 457660 KB Partially correct
3 Correct 707 ms 457708 KB Output is correct
4 Partially correct 673 ms 457652 KB Partially correct
5 Partially correct 675 ms 457816 KB Partially correct
6 Partially correct 662 ms 457812 KB Partially correct
7 Partially correct 682 ms 457812 KB Partially correct
8 Partially correct 762 ms 457660 KB Partially correct
9 Partially correct 763 ms 457760 KB Partially correct
10 Partially correct 825 ms 457808 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 164 ms 451668 KB Output is correct
2 Partially correct 768 ms 457660 KB Partially correct
3 Correct 707 ms 457708 KB Output is correct
4 Partially correct 673 ms 457652 KB Partially correct
5 Partially correct 675 ms 457816 KB Partially correct
6 Partially correct 662 ms 457812 KB Partially correct
7 Partially correct 682 ms 457812 KB Partially correct
8 Partially correct 762 ms 457660 KB Partially correct
9 Partially correct 763 ms 457760 KB Partially correct
10 Partially correct 825 ms 457808 KB Partially correct
11 Correct 160 ms 451668 KB Output is correct
12 Partially correct 762 ms 457648 KB Partially correct
13 Correct 750 ms 457648 KB Output is correct
14 Partially correct 692 ms 457648 KB Partially correct
15 Partially correct 664 ms 457876 KB Partially correct
16 Partially correct 662 ms 457808 KB Partially correct
17 Partially correct 696 ms 457808 KB Partially correct
18 Partially correct 764 ms 457716 KB Partially correct
19 Partially correct 767 ms 457848 KB Partially correct
20 Partially correct 737 ms 457656 KB Partially correct
21 Correct 157 ms 451664 KB Output is correct
22 Correct 152 ms 451568 KB Output is correct
23 Partially correct 159 ms 451604 KB Partially correct
24 Correct 156 ms 451668 KB Output is correct
25 Partially correct 159 ms 451724 KB Partially correct
26 Partially correct 161 ms 451712 KB Partially correct
27 Correct 168 ms 451664 KB Output is correct
28 Partially correct 173 ms 451664 KB Partially correct
29 Partially correct 163 ms 451664 KB Partially correct
30 Partially correct 173 ms 451668 KB Partially correct
31 Correct 699 ms 457812 KB Output is correct
32 Partially correct 667 ms 457808 KB Partially correct
33 Partially correct 847 ms 457808 KB Partially correct
34 Partially correct 761 ms 457808 KB Partially correct
35 Partially correct 782 ms 457740 KB Partially correct
36 Partially correct 671 ms 457812 KB Partially correct
37 Partially correct 790 ms 457660 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 152 ms 451536 KB Output is correct
2 Correct 161 ms 451664 KB Output is correct
3 Correct 153 ms 451648 KB Output is correct
4 Correct 174 ms 451740 KB Output is correct
5 Correct 153 ms 451668 KB Output is correct
6 Partially correct 163 ms 451624 KB Partially correct
7 Correct 175 ms 451552 KB Output is correct
8 Partially correct 165 ms 451704 KB Partially correct
9 Partially correct 254 ms 451672 KB Partially correct
10 Correct 150 ms 451668 KB Output is correct
11 Partially correct 154 ms 451588 KB Partially correct
12 Partially correct 161 ms 451664 KB Partially correct
13 Partially correct 150 ms 451576 KB Partially correct
14 Correct 157 ms 451668 KB Output is correct
15 Correct 162 ms 451620 KB Output is correct
16 Correct 165 ms 451664 KB Output is correct
17 Partially correct 151 ms 451668 KB Partially correct
18 Correct 164 ms 451668 KB Output is correct
19 Partially correct 167 ms 451664 KB Partially correct
20 Partially correct 159 ms 451668 KB Partially correct
21 Correct 159 ms 451664 KB Output is correct
22 Partially correct 158 ms 451664 KB Partially correct
23 Partially correct 163 ms 451664 KB Partially correct
24 Partially correct 163 ms 451668 KB Partially correct
25 Incorrect 175 ms 451668 KB Output isn't correct
26 Halted 0 ms 0 KB -