# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
525547 | 2022-02-11T22:10:39 Z | Yazan_Alattar | Kitchen (BOI19_kitchen) | C++14 | 1000 ms | 16096 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second #define pb push_back #define endl "\n" #define all(x) x.begin(), x.end() const int M = 4005; const ll inf = 1e18; const ll mod = 998244353; const double pi = acos(-1); const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; int n, m, k, sum, a[M], b[M], tot; bool dp[M][M]; int main() { scanf("%d%d%d", &n, &m, &k); for(int i = 1; i <= n; ++i) { scanf("%d", &a[i]); sum += a[i]; if(a[i] < k) printf("Impossible\n"), exit(0); } for(int i = 1; i <= m; ++i) scanf("%d", &b[i]), tot += b[i]; if(sum > tot) printf("Impossible\n"), exit(0); dp[0][0] = 1; for(int i = 1; i <= m; ++i) { for(int cost = M - b[i] - 1; cost >= 0; --cost) { for(int filled = 0; filled + min(n, b[i]) < M; ++filled) { dp[filled + min(n, b[i])][cost + b[i]] |= dp[filled][cost]; } } for(int cost = M - b[i] - 1; cost >= 0; --cost) for(int filled = M - 2; filled >= 0; --filled) dp[filled][cost] |= dp[filled + 1][cost]; } for(int i = sum; i < M; ++i) if(dp[n * k][i]) printf("%d\n", i - sum), exit(0); printf("Impossible\n"); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 494 ms | 15972 KB | Output is correct |
2 | Correct | 497 ms | 15968 KB | Output is correct |
3 | Correct | 487 ms | 16096 KB | Output is correct |
4 | Correct | 533 ms | 15976 KB | Output is correct |
5 | Correct | 494 ms | 15972 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 494 ms | 15972 KB | Output is correct |
2 | Correct | 497 ms | 15968 KB | Output is correct |
3 | Correct | 487 ms | 16096 KB | Output is correct |
4 | Correct | 533 ms | 15976 KB | Output is correct |
5 | Correct | 494 ms | 15972 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Execution timed out | 1087 ms | 15944 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1080 ms | 15888 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1084 ms | 15872 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 494 ms | 15972 KB | Output is correct |
2 | Correct | 497 ms | 15968 KB | Output is correct |
3 | Correct | 487 ms | 16096 KB | Output is correct |
4 | Correct | 533 ms | 15976 KB | Output is correct |
5 | Correct | 494 ms | 15972 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Execution timed out | 1087 ms | 15944 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |