답안 #577805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
577805 2022-06-15T09:25:43 Z kingfran1907 Uplifting Excursion (BOI22_vault) C++14
0 / 100
287 ms 16460 KB
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long llint;

const int maxn = 101;
const int buf = maxn * maxn;
const int inf = 0x3f3f3f3f;

int n;
llint l;
int niz[2 * maxn];
int dp[2 * maxn][2 * maxn * maxn];

int f(int x, int val) {
	if (x == n + 1) {
		if (val == l) return 0;
		else return -inf;
	}
	int &ret = dp[x + maxn][val + buf];
	if (ret != -1) return ret;
	
	ret = -inf;
	for (int i = 0; i <= niz[x + n]; i++) {
		ret = max(ret, i + f(x + 1, val + i * x));
	}
	return ret;
}

int main() {
	scanf("%d%lld\n", &n, &l);
	for (int i = 0; i < n + n + 1; i++)
		scanf("%d", niz+i);
		
	memset(dp, -1, sizeof dp);
	int out = f(-n, 0);
	if (out < 0) printf("impossible\n");
	else printf("%d\n", out);
	return 0;
}

Compilation message

vault.cpp: In function 'int main()':
vault.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |  scanf("%d%lld\n", &n, &l);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~
vault.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |   scanf("%d", niz+i);
      |   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 16340 KB Output is correct
2 Correct 8 ms 16420 KB Output is correct
3 Correct 7 ms 16408 KB Output is correct
4 Correct 7 ms 16384 KB Output is correct
5 Correct 265 ms 16416 KB Output is correct
6 Incorrect 287 ms 16460 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 16340 KB Output is correct
2 Correct 8 ms 16420 KB Output is correct
3 Correct 7 ms 16408 KB Output is correct
4 Correct 7 ms 16384 KB Output is correct
5 Correct 265 ms 16416 KB Output is correct
6 Incorrect 287 ms 16460 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 16340 KB Output is correct
2 Incorrect 7 ms 16340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 16340 KB Output is correct
2 Incorrect 7 ms 16340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 16340 KB Output is correct
2 Incorrect 7 ms 16340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 16340 KB Output is correct
2 Correct 8 ms 16420 KB Output is correct
3 Correct 7 ms 16408 KB Output is correct
4 Correct 7 ms 16384 KB Output is correct
5 Correct 265 ms 16416 KB Output is correct
6 Incorrect 287 ms 16460 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 16340 KB Output is correct
2 Incorrect 7 ms 16340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 16340 KB Output is correct
2 Correct 8 ms 16420 KB Output is correct
3 Correct 7 ms 16408 KB Output is correct
4 Correct 7 ms 16384 KB Output is correct
5 Correct 265 ms 16416 KB Output is correct
6 Incorrect 287 ms 16460 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 16340 KB Output is correct
2 Incorrect 7 ms 16340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 16340 KB Output is correct
2 Correct 8 ms 16420 KB Output is correct
3 Correct 7 ms 16408 KB Output is correct
4 Correct 7 ms 16384 KB Output is correct
5 Correct 265 ms 16416 KB Output is correct
6 Incorrect 287 ms 16460 KB Output isn't correct
7 Halted 0 ms 0 KB -