답안 #477504

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
477504 2021-10-02T10:36:34 Z Sohsoh84 Kitchen (BOI19_kitchen) C++17
100 / 100
83 ms 108460 KB
// ¯\_(ツ)_/¯
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
 
#define all(x)                      (x).begin(),(x).end()
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << ": " <<  x << endl;
 
const ll MAXN = 300 + 3;
const ll INF = 1e9;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;
 
int dp[MAXN][MAXN * MAXN], n, m, k, B[MAXN], A[MAXN], s;
 
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		cin >> A[i];
		if (A[i] < k) return cout << "Impossible" << endl, 0;
		s += A[i];
	}
	
	for (int j = 1; j <= m; j++) cin >> B[j];
 
	fill(dp[0], dp[0] + MAXN * MAXN, -INF);
	dp[0][0] = 0;
 
	for (int i = 1; i <= m; i++) {
		for (int h = 0; h < MAXN * MAXN; h++) {
			dp[i][h] = dp[i - 1][h];
			int c = min(n, B[i]);
			if (h >= B[i]) dp[i][h] = max(dp[i][h], dp[i - 1][h - B[i]] + c);
		}
	}
	
	for (int i = s; i < MAXN * MAXN; i++)
		if (dp[m][i] >= n * k)
			return cout << i - s << endl, 0;
	cout << "Impossible" << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1360 KB Output is correct
2 Correct 1 ms 1360 KB Output is correct
3 Correct 1 ms 1360 KB Output is correct
4 Correct 1 ms 1360 KB Output is correct
5 Correct 1 ms 1360 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 1348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1360 KB Output is correct
2 Correct 1 ms 1360 KB Output is correct
3 Correct 1 ms 1360 KB Output is correct
4 Correct 1 ms 1360 KB Output is correct
5 Correct 1 ms 1360 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 1348 KB Output is correct
9 Correct 4 ms 5968 KB Output is correct
10 Correct 4 ms 5968 KB Output is correct
11 Correct 6 ms 5968 KB Output is correct
12 Correct 5 ms 5956 KB Output is correct
13 Correct 5 ms 5968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 94336 KB Output is correct
2 Correct 58 ms 81836 KB Output is correct
3 Correct 78 ms 108432 KB Output is correct
4 Correct 76 ms 108460 KB Output is correct
5 Correct 75 ms 104864 KB Output is correct
6 Correct 55 ms 75328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 15160 KB Output is correct
2 Correct 12 ms 15048 KB Output is correct
3 Correct 11 ms 15056 KB Output is correct
4 Correct 12 ms 15028 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1360 KB Output is correct
2 Correct 1 ms 1360 KB Output is correct
3 Correct 1 ms 1360 KB Output is correct
4 Correct 1 ms 1360 KB Output is correct
5 Correct 1 ms 1360 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 1348 KB Output is correct
9 Correct 4 ms 5968 KB Output is correct
10 Correct 4 ms 5968 KB Output is correct
11 Correct 6 ms 5968 KB Output is correct
12 Correct 5 ms 5956 KB Output is correct
13 Correct 5 ms 5968 KB Output is correct
14 Correct 66 ms 94336 KB Output is correct
15 Correct 58 ms 81836 KB Output is correct
16 Correct 78 ms 108432 KB Output is correct
17 Correct 76 ms 108460 KB Output is correct
18 Correct 75 ms 104864 KB Output is correct
19 Correct 55 ms 75328 KB Output is correct
20 Correct 12 ms 15160 KB Output is correct
21 Correct 12 ms 15048 KB Output is correct
22 Correct 11 ms 15056 KB Output is correct
23 Correct 12 ms 15028 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 53 ms 76060 KB Output is correct
26 Correct 62 ms 87880 KB Output is correct
27 Correct 41 ms 58132 KB Output is correct
28 Correct 67 ms 88272 KB Output is correct
29 Correct 64 ms 90444 KB Output is correct
30 Correct 83 ms 108444 KB Output is correct