Submission #1046577

# Submission time Handle Problem Language Result Execution time Memory
1046577 2024-08-06T17:32:35 Z vjudge1 Uplifting Excursion (BOI22_vault) C++17
0 / 100
5000 ms 524288 KB
#include <bits/stdc++.h>

using namespace std;

#define ar array
#define int long long
#define ld long double

const int N = 5e6 + 20;
const int X = 7e5 + 20;

const int LOG = 21;
const int INF = 1e17;

int dp[2][N];

signed main(){ios::sync_with_stdio(false);cin.tie(0);	
	int n, m;
	cin>>n>>m;
	vector<int> v;
	for(int i = -n;i <= n;i++){
		int x;
		cin>>x;
		for(int j = 0;j < x;j++)v.push_back(i);
	}
	memset(dp, -1,sizeof dp);
	dp[0][X] = 0;
	int k = 0;
	for(auto u: v){
		memcpy(dp[k ^ 1], dp[k], sizeof dp[k]);
		for(int i = 0;i < N;i++){
			if(dp[k][i] == -1)continue;
			dp[k ^ 1][i + u] = max(dp[k ^ 1][i + u], dp[k][i] + 1);
		}
		k ^= 1;
	}
	if(dp[k][X + m] != -1)cout<<dp[k][X + m];
	else cout<<"impossible";
}
# Verdict Execution time Memory Grader output
1 Correct 57 ms 78684 KB Output is correct
2 Correct 45 ms 78680 KB Output is correct
3 Correct 36 ms 78684 KB Output is correct
4 Correct 298 ms 78716 KB Output is correct
5 Execution timed out 5050 ms 78684 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 57 ms 78684 KB Output is correct
2 Correct 45 ms 78680 KB Output is correct
3 Correct 36 ms 78684 KB Output is correct
4 Correct 298 ms 78716 KB Output is correct
5 Execution timed out 5050 ms 78684 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 306 ms 78680 KB Output is correct
2 Runtime error 186 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 306 ms 78680 KB Output is correct
2 Runtime error 186 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 306 ms 78680 KB Output is correct
2 Runtime error 186 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 57 ms 78684 KB Output is correct
2 Correct 45 ms 78680 KB Output is correct
3 Correct 36 ms 78684 KB Output is correct
4 Correct 298 ms 78716 KB Output is correct
5 Execution timed out 5050 ms 78684 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 306 ms 78680 KB Output is correct
2 Runtime error 186 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 57 ms 78684 KB Output is correct
2 Correct 45 ms 78680 KB Output is correct
3 Correct 36 ms 78684 KB Output is correct
4 Correct 298 ms 78716 KB Output is correct
5 Execution timed out 5050 ms 78684 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 306 ms 78680 KB Output is correct
2 Runtime error 186 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 57 ms 78684 KB Output is correct
2 Correct 45 ms 78680 KB Output is correct
3 Correct 36 ms 78684 KB Output is correct
4 Correct 298 ms 78716 KB Output is correct
5 Execution timed out 5050 ms 78684 KB Time limit exceeded
6 Halted 0 ms 0 KB -