Submission #588649

# Submission time Handle Problem Language Result Execution time Memory
588649 2022-07-03T19:06:32 Z peuch Uplifting Excursion (BOI22_vault) C++17
5 / 100
917 ms 2388 KB
#include<bits/stdc++.h>
using namespace std;

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

long long m;
long long l;

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

int main(){
	
	scanf("%lld %lld", &m, &l);
	long long sum = 0;
	long long cnt = 0;
	for(long long i = -m; i <= m; i++){
		scanf("%lld", &v[i + m]);
		sum += v[i + m] * i;
		cnt += v[i + m];
	}
	
	if(l + HALF >= MAXN * MAXN * MAXN || l + HALF < 0){
		printf("impossible\n");
		return 0;
	} 
	
	for(long long j = 0; j < MAXN * MAXN * MAXN; j++)
		dp[1][j] = INF;
	
	dp[1][HALF] = 0;
	for(long long i = 0; i <= 2 * m; i++){
		for(long long k = 0; k < v[i]; k++){
			for(long long j = 0; j < MAXN * MAXN * MAXN; j++)
				dp[0][j] = dp[1][j];
			for(long long j = 0; j < MAXN * MAXN * MAXN; j++){
				dp[1][j] = dp[0][j];
				if(j - (i - m - 1) < MAXN * MAXN * MAXN && j - (i - m) >= 0) dp[1][j] = min(dp[1][j], dp[0][j - (i - m)] + 1);
			}
		}
	}
	
	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:16:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  scanf("%lld %lld", &m, &l);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
vault.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf("%lld", &v[i + m]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2260 KB Output is correct
2 Correct 3 ms 2260 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 12 ms 2260 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 512 ms 2360 KB Output is correct
7 Correct 189 ms 2352 KB Output is correct
8 Correct 456 ms 2356 KB Output is correct
9 Correct 868 ms 2360 KB Output is correct
10 Correct 21 ms 2388 KB Output is correct
11 Correct 20 ms 2380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2260 KB Output is correct
2 Correct 3 ms 2260 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 12 ms 2260 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 512 ms 2360 KB Output is correct
7 Correct 189 ms 2352 KB Output is correct
8 Correct 456 ms 2356 KB Output is correct
9 Correct 868 ms 2360 KB Output is correct
10 Correct 21 ms 2388 KB Output is correct
11 Correct 20 ms 2380 KB Output is correct
12 Correct 5 ms 2260 KB Output is correct
13 Correct 3 ms 2260 KB Output is correct
14 Correct 2 ms 2260 KB Output is correct
15 Correct 13 ms 2372 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 493 ms 2356 KB Output is correct
18 Correct 197 ms 2260 KB Output is correct
19 Correct 473 ms 2352 KB Output is correct
20 Correct 917 ms 2360 KB Output is correct
21 Correct 27 ms 2376 KB Output is correct
22 Correct 16 ms 2380 KB Output is correct
23 Incorrect 877 ms 2356 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2380 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 12 ms 2380 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 12 ms 2380 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 3 ms 2260 KB Output is correct
2 Correct 3 ms 2260 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 12 ms 2260 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 512 ms 2360 KB Output is correct
7 Correct 189 ms 2352 KB Output is correct
8 Correct 456 ms 2356 KB Output is correct
9 Correct 868 ms 2360 KB Output is correct
10 Correct 21 ms 2388 KB Output is correct
11 Correct 20 ms 2380 KB Output is correct
12 Correct 12 ms 2380 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 12 ms 2380 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 3 ms 2260 KB Output is correct
2 Correct 3 ms 2260 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 12 ms 2260 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 512 ms 2360 KB Output is correct
7 Correct 189 ms 2352 KB Output is correct
8 Correct 456 ms 2356 KB Output is correct
9 Correct 868 ms 2360 KB Output is correct
10 Correct 21 ms 2388 KB Output is correct
11 Correct 20 ms 2380 KB Output is correct
12 Correct 5 ms 2260 KB Output is correct
13 Correct 3 ms 2260 KB Output is correct
14 Correct 2 ms 2260 KB Output is correct
15 Correct 13 ms 2372 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 493 ms 2356 KB Output is correct
18 Correct 197 ms 2260 KB Output is correct
19 Correct 473 ms 2352 KB Output is correct
20 Correct 917 ms 2360 KB Output is correct
21 Correct 27 ms 2376 KB Output is correct
22 Correct 16 ms 2380 KB Output is correct
23 Incorrect 877 ms 2356 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2380 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 3 ms 2260 KB Output is correct
2 Correct 3 ms 2260 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 12 ms 2260 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 512 ms 2360 KB Output is correct
7 Correct 189 ms 2352 KB Output is correct
8 Correct 456 ms 2356 KB Output is correct
9 Correct 868 ms 2360 KB Output is correct
10 Correct 21 ms 2388 KB Output is correct
11 Correct 20 ms 2380 KB Output is correct
12 Correct 5 ms 2260 KB Output is correct
13 Correct 3 ms 2260 KB Output is correct
14 Correct 2 ms 2260 KB Output is correct
15 Correct 13 ms 2372 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 493 ms 2356 KB Output is correct
18 Correct 197 ms 2260 KB Output is correct
19 Correct 473 ms 2352 KB Output is correct
20 Correct 917 ms 2360 KB Output is correct
21 Correct 27 ms 2376 KB Output is correct
22 Correct 16 ms 2380 KB Output is correct
23 Incorrect 877 ms 2356 KB Output isn't correct
24 Halted 0 ms 0 KB -