# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
874150 |
2023-11-16T10:50:56 Z |
vjudge1 |
Kitchen (BOI19_kitchen) |
C++17 |
|
27 ms |
828 KB |
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int MAXN = 300 + 5;
int dp[MAXN * MAXN];
#define ONLINE_JUDGE
void solve() {
fill_n(&dp[0], MAXN * MAXN, int(-1E4));
int n, m, k;
cin >> n >> m >> k;
vector <int> a(n);
for(int &i : a)
cin >> i;
vector <int> b(m);
for(int &i : b)
cin >> i;
bool ans = (k <= m);
for(int &i : a)
ans &= (k <= i);
int suma = accumulate(a.begin(), a.end(), 0);
ans &= (suma <= accumulate(b.begin(), b.end(), 0));
if(!ans) {
return cout << "Impossible", void();
}
dp[0] = 0;
for(int i = 0; i < m; i++) {
for(int j = MAXN * MAXN -1; j >= b[i]; j--) {
dp[j] = max(dp[j], dp[j - b[i]] +1);
}
}
int cev = MAXN * MAXN +1;
for(int i = MAXN * MAXN -1; i >= suma; i--) {
if(dp[i] >= k) {
cev = i;
}
}
if(cev == MAXN * MAXN +1)
cout << "Impossible";
else
cout << cev - suma;
return;
}
signed main() {
#ifndef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int t = 1; //cin >> t;
for(int i = 1; i <= t; i++) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
824 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
824 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
604 KB |
Output is correct |
10 |
Correct |
2 ms |
824 KB |
Output is correct |
11 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
828 KB |
Output is correct |
2 |
Correct |
20 ms |
600 KB |
Output is correct |
3 |
Correct |
27 ms |
604 KB |
Output is correct |
4 |
Correct |
27 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
600 KB |
Output is correct |
6 |
Correct |
19 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
824 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
604 KB |
Output is correct |
10 |
Correct |
2 ms |
824 KB |
Output is correct |
11 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |