# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
377319 |
2021-03-13T21:46:06 Z |
hhh07 |
Kitchen (BOI19_kitchen) |
C++14 |
|
28 ms |
1024 KB |
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <climits>
#include <vector>
#include <queue>
#include <utility>
#include <iomanip>
#include <cstring>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
ll n, m, k;
cin >> n >> m >> k;
ll a[n], b[m];
ll sum = 0;
for (ll i = 0; i < n; i++){
cin >> a[i];
sum += a[i];
if (a[i] < k){
cout << "Impossible";
return 0;
}
}
for (ll i = 0; i < m; i++)
cin >> b[i];
if (k > m){
cout << "Impossible";
return 0;
}
vector<ll> dp(90001, (ll)-1e6);
dp[0] = 0;
for (ll i = 0; i < m; i++){
for (ll j = 90000 - b[i]; j >= 0 ; j--){
dp[j + b[i]] = max(dp[j + b[i]], dp[j] + min(n, b[i]));
}
}
for (ll i = sum; i < 90001; i++){
if (dp[i] >= n*k){
cout << i - sum << endl;
return 0;
}
}
cout << "Impossible";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1004 KB |
Output is correct |
2 |
Correct |
1 ms |
1004 KB |
Output is correct |
3 |
Correct |
1 ms |
1004 KB |
Output is correct |
4 |
Correct |
1 ms |
1004 KB |
Output is correct |
5 |
Correct |
1 ms |
1004 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
1004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1004 KB |
Output is correct |
2 |
Correct |
1 ms |
1004 KB |
Output is correct |
3 |
Correct |
1 ms |
1004 KB |
Output is correct |
4 |
Correct |
1 ms |
1004 KB |
Output is correct |
5 |
Correct |
1 ms |
1004 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
1004 KB |
Output is correct |
9 |
Correct |
2 ms |
1004 KB |
Output is correct |
10 |
Correct |
2 ms |
1004 KB |
Output is correct |
11 |
Correct |
2 ms |
1004 KB |
Output is correct |
12 |
Correct |
2 ms |
1004 KB |
Output is correct |
13 |
Correct |
2 ms |
1004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1004 KB |
Output is correct |
2 |
Correct |
22 ms |
1024 KB |
Output is correct |
3 |
Correct |
28 ms |
1004 KB |
Output is correct |
4 |
Correct |
28 ms |
1004 KB |
Output is correct |
5 |
Correct |
27 ms |
1024 KB |
Output is correct |
6 |
Correct |
19 ms |
1004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1004 KB |
Output is correct |
2 |
Correct |
5 ms |
1004 KB |
Output is correct |
3 |
Correct |
5 ms |
1004 KB |
Output is correct |
4 |
Correct |
5 ms |
1004 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1004 KB |
Output is correct |
2 |
Correct |
1 ms |
1004 KB |
Output is correct |
3 |
Correct |
1 ms |
1004 KB |
Output is correct |
4 |
Correct |
1 ms |
1004 KB |
Output is correct |
5 |
Correct |
1 ms |
1004 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
1004 KB |
Output is correct |
9 |
Correct |
2 ms |
1004 KB |
Output is correct |
10 |
Correct |
2 ms |
1004 KB |
Output is correct |
11 |
Correct |
2 ms |
1004 KB |
Output is correct |
12 |
Correct |
2 ms |
1004 KB |
Output is correct |
13 |
Correct |
2 ms |
1004 KB |
Output is correct |
14 |
Correct |
24 ms |
1004 KB |
Output is correct |
15 |
Correct |
22 ms |
1024 KB |
Output is correct |
16 |
Correct |
28 ms |
1004 KB |
Output is correct |
17 |
Correct |
28 ms |
1004 KB |
Output is correct |
18 |
Correct |
27 ms |
1024 KB |
Output is correct |
19 |
Correct |
19 ms |
1004 KB |
Output is correct |
20 |
Correct |
5 ms |
1004 KB |
Output is correct |
21 |
Correct |
5 ms |
1004 KB |
Output is correct |
22 |
Correct |
5 ms |
1004 KB |
Output is correct |
23 |
Correct |
5 ms |
1004 KB |
Output is correct |
24 |
Correct |
1 ms |
364 KB |
Output is correct |
25 |
Correct |
19 ms |
1004 KB |
Output is correct |
26 |
Correct |
23 ms |
1004 KB |
Output is correct |
27 |
Correct |
15 ms |
1004 KB |
Output is correct |
28 |
Correct |
22 ms |
1004 KB |
Output is correct |
29 |
Correct |
23 ms |
1004 KB |
Output is correct |
30 |
Correct |
27 ms |
1004 KB |
Output is correct |