Submission #601192

# Submission time Handle Problem Language Result Execution time Memory
601192 2022-07-21T12:56:41 Z CSQ31 Uplifting Excursion (BOI22_vault) C++17
5 / 100
210 ms 15968 KB
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
typedef long long int ll;
ll A[5000],B[5000];
unordered_map<ll,ll>val;
ll dp[2000001];
int main()
{
	int m;
	ll L;
	cin>>m>>L;
	for(int i=-m;i<=m;i++)cin>>A[i+m];
	ll ans = A[m];
	/*
	//subtask 2 m^4 knapsack??
	//consider left and right side separately
	//let ai be number of art piece i chosen
	//1)atleast one of ai , a_{-i} must be 0
	//2)consider only positive
	//ai aj i<j
	//if aj >= i and ai <= Ai-j
	//do ai+=j aj-=i
	//j > i
	//ai <= Ai-M and aj >= M cant be both true
	//a prefix p has ai>Ai-M then p+1 can be anything
	//ahhhhhhhhh iterate first i such that ai <= M
	for(int i=1;i<=m;i++){
	}
	*/
	ll shift = 100500;
	if(L > shift || L < -shift){
		cout<<"impossible"<<'\n';
		return 0;
	}
	for(int i=0;i<=2000000;i++)dp[i] = -1;
	dp[shift] = 0;
	for(ll i=-m;i<=m;i++){
		if(i==0)continue;
		ll z = 1;
		vector<ll>item;
		while(A[i+m]>=z){
			item.push_back(z);
			A[i+m]-=z;
			z*=2;
		}
		if(A[i+m])item.push_back(A[i+m]);
		if(i < 0){
			for(ll x:item){
				for(ll j=-shift-x*i;j<=shift;j++){
					if(dp[j+shift] != -1)dp[j + x*i+shift] = max(dp[j + x*i+shift],dp[j+shift] + x);
				}
			}
		}else{
			for(ll x:item){
				for(ll j=shift-x*i;j>=-shift;j--){
					if(dp[j+shift] != -1)dp[j + x*i+shift] = max(dp[j + x*i+shift],dp[j+shift] + x);
				}
			}			
			
		}
	}
	if(dp[L+shift] == -1){
		cout<<"impossible"<<'\n';
		return 0;
	}
	ans+=dp[L+shift];
	cout<<ans<<'\n';
	
	
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 15956 KB Output is correct
2 Correct 7 ms 15956 KB Output is correct
3 Correct 7 ms 15956 KB Output is correct
4 Correct 10 ms 15956 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 88 ms 15956 KB Output is correct
7 Correct 46 ms 15956 KB Output is correct
8 Correct 82 ms 15956 KB Output is correct
9 Correct 98 ms 15940 KB Output is correct
10 Correct 8 ms 15956 KB Output is correct
11 Correct 9 ms 15912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 15956 KB Output is correct
2 Correct 7 ms 15956 KB Output is correct
3 Correct 7 ms 15956 KB Output is correct
4 Correct 10 ms 15956 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 88 ms 15956 KB Output is correct
7 Correct 46 ms 15956 KB Output is correct
8 Correct 82 ms 15956 KB Output is correct
9 Correct 98 ms 15940 KB Output is correct
10 Correct 8 ms 15956 KB Output is correct
11 Correct 9 ms 15912 KB Output is correct
12 Correct 7 ms 15924 KB Output is correct
13 Correct 7 ms 15956 KB Output is correct
14 Correct 7 ms 15924 KB Output is correct
15 Correct 11 ms 15964 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 80 ms 15944 KB Output is correct
18 Correct 35 ms 15952 KB Output is correct
19 Correct 75 ms 15828 KB Output is correct
20 Correct 102 ms 15956 KB Output is correct
21 Correct 8 ms 15968 KB Output is correct
22 Correct 9 ms 15956 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Incorrect 210 ms 15956 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 15964 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 15964 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 15964 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 15956 KB Output is correct
2 Correct 7 ms 15956 KB Output is correct
3 Correct 7 ms 15956 KB Output is correct
4 Correct 10 ms 15956 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 88 ms 15956 KB Output is correct
7 Correct 46 ms 15956 KB Output is correct
8 Correct 82 ms 15956 KB Output is correct
9 Correct 98 ms 15940 KB Output is correct
10 Correct 8 ms 15956 KB Output is correct
11 Correct 9 ms 15912 KB Output is correct
12 Correct 10 ms 15964 KB Output is correct
13 Incorrect 0 ms 212 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 15964 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 15956 KB Output is correct
2 Correct 7 ms 15956 KB Output is correct
3 Correct 7 ms 15956 KB Output is correct
4 Correct 10 ms 15956 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 88 ms 15956 KB Output is correct
7 Correct 46 ms 15956 KB Output is correct
8 Correct 82 ms 15956 KB Output is correct
9 Correct 98 ms 15940 KB Output is correct
10 Correct 8 ms 15956 KB Output is correct
11 Correct 9 ms 15912 KB Output is correct
12 Correct 7 ms 15924 KB Output is correct
13 Correct 7 ms 15956 KB Output is correct
14 Correct 7 ms 15924 KB Output is correct
15 Correct 11 ms 15964 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 80 ms 15944 KB Output is correct
18 Correct 35 ms 15952 KB Output is correct
19 Correct 75 ms 15828 KB Output is correct
20 Correct 102 ms 15956 KB Output is correct
21 Correct 8 ms 15968 KB Output is correct
22 Correct 9 ms 15956 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Incorrect 210 ms 15956 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 15964 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 15956 KB Output is correct
2 Correct 7 ms 15956 KB Output is correct
3 Correct 7 ms 15956 KB Output is correct
4 Correct 10 ms 15956 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 88 ms 15956 KB Output is correct
7 Correct 46 ms 15956 KB Output is correct
8 Correct 82 ms 15956 KB Output is correct
9 Correct 98 ms 15940 KB Output is correct
10 Correct 8 ms 15956 KB Output is correct
11 Correct 9 ms 15912 KB Output is correct
12 Correct 7 ms 15924 KB Output is correct
13 Correct 7 ms 15956 KB Output is correct
14 Correct 7 ms 15924 KB Output is correct
15 Correct 11 ms 15964 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 80 ms 15944 KB Output is correct
18 Correct 35 ms 15952 KB Output is correct
19 Correct 75 ms 15828 KB Output is correct
20 Correct 102 ms 15956 KB Output is correct
21 Correct 8 ms 15968 KB Output is correct
22 Correct 9 ms 15956 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Incorrect 210 ms 15956 KB Output isn't correct
25 Halted 0 ms 0 KB -