Submission #963655

# Submission time Handle Problem Language Result Execution time Memory
963655 2024-04-15T12:29:44 Z NotLinux Uplifting Excursion (BOI22_vault) C++17
0 / 100
81 ms 860 KB
//author : FatihCihan
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
const int inf = 1e9 + 7;
const int N = 1e4 + 7;
void solve(){
	int m,l;
	cin >> m >> l;
	vector < int > v;
	for(int i = -m;i<=m;i++){
		int x;
		cin >> x;
		for(int j = 0;j<x;j++){
			v.push_back(i);
		}
	}
	vector < int > knapsack(2 * N + 1 , -inf);
	knapsack[N] = 0;
	// for(int i = 0;i<=2*N;i++){
	// 	cout << i - N << " : " << knapsack[i] << endl;
	// }
	// cout << endl;
	for(auto itr : v){
		vector < int > newknapsack = knapsack;
		for(int i = 0;i<=2*N;i++){
			newknapsack[i] = max(newknapsack[i] , knapsack[i]);
			if((i - itr) <= 2*N and (i - itr) >= 0){
				newknapsack[i] = max(newknapsack[i] , knapsack[i - itr] + 1);
			}
		}
		swap(knapsack , newknapsack);
		// for(int i = 0;i<=2*N;i++){
		// 	cout << i - N << " : " << knapsack[i] << endl;
		// }
	}
	// cout << endl;
	// for(int i = 0;i<=2*N;i++){
	// 	cout << i - N << " : " << knapsack[i] << endl;
	// }
	// cout << endl;
	if(abs(l) <= N){
		if(knapsack[l + N] > m)cout << knapsack[l + N] << endl;
		else cout << "impossible" << endl;
	}
	else{
		cout << "impossible" << endl;
	}
}
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int testcase = 1;//cin >> testcase;
	while(testcase--)solve();
	cerr << 1000.0 * clock() / CLOCKS_PER_SEC << " ms" << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Incorrect 81 ms 616 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Incorrect 81 ms 616 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Incorrect 2 ms 600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Incorrect 2 ms 600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Incorrect 2 ms 600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Incorrect 81 ms 616 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Incorrect 2 ms 600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Incorrect 81 ms 616 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Incorrect 2 ms 600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Incorrect 81 ms 616 KB Output isn't correct
7 Halted 0 ms 0 KB -