Submission #588654

# Submission time Handle Problem Language Result Execution time Memory
588654 2022-07-03T19:18:59 Z peuch Uplifting Excursion (BOI22_vault) C++17
0 / 100
1170 ms 145308 KB
#include<bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

const long long MAXN = 210;
const long long MAXA = MAXN * MAXN * MAXN;
const long long INF = 1e18;
const long long HALF = MAXA / 2;

long long m;
long long l;

long long v[2 * MAXN];
long long dp[2][MAXA];

int main(){
	
	scanf("%lld %lld", &m, &l);
	long long sum = 0;
	long long cnt = 0;
	vector<pair<long long, long long> > moedas;
	for(long long i = -m; i <= m; i++){
		scanf("%lld", &v[i + m]);
		sum += v[i + m] * i;
		cnt += v[i + m];
		long long aux = v[i + m];
		int tam = 1;
		long long val = i;
		while(aux > 0){
			moedas.push_back(make_pair(val, tam));
			aux--;
			if(aux % 2 == 1){
				moedas.push_back(make_pair(val, tam));
				aux--;
			}
			aux /= 2;
			val *= 2;
		}
	}
	
	if(l + HALF >= MAXA || l + HALF < 0){
		printf("impossible\n");
		return 0;
	} 
	
	for(long long j = 0; j < MAXA; j++)
		dp[1][j] = INF;
	
	dp[1][HALF] = 0;
	
	for(auto val : moedas){
		swap(dp[0], dp[1]);
		for(long long j = 0; j < MAXA; j++){
			dp[1][j] = dp[0][j];
			if(j - val.first < MAXA && j - val.first >= 0) dp[1][j] = min(dp[1][j], dp[0][j - val.first] + val.second);
		}
	}
	
	if(dp[1][sum - l + HALF] == INF) printf("impossible\n");
	else printf("%lld\n", cnt - dp[1][sum - l + HALF]);
}

Compilation message

vault.cpp: In function 'int main()':
vault.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  scanf("%lld %lld", &m, &l);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
vault.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |   scanf("%lld", &v[i + m]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 349 ms 145292 KB Output is correct
2 Correct 296 ms 145308 KB Output is correct
3 Correct 196 ms 145160 KB Output is correct
4 Incorrect 1104 ms 145272 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 349 ms 145292 KB Output is correct
2 Correct 296 ms 145308 KB Output is correct
3 Correct 196 ms 145160 KB Output is correct
4 Incorrect 1104 ms 145272 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1170 ms 145268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1170 ms 145268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1170 ms 145268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 349 ms 145292 KB Output is correct
2 Correct 296 ms 145308 KB Output is correct
3 Correct 196 ms 145160 KB Output is correct
4 Incorrect 1104 ms 145272 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1170 ms 145268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 349 ms 145292 KB Output is correct
2 Correct 296 ms 145308 KB Output is correct
3 Correct 196 ms 145160 KB Output is correct
4 Incorrect 1104 ms 145272 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1170 ms 145268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 349 ms 145292 KB Output is correct
2 Correct 296 ms 145308 KB Output is correct
3 Correct 196 ms 145160 KB Output is correct
4 Incorrect 1104 ms 145272 KB Output isn't correct
5 Halted 0 ms 0 KB -