# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
926012 |
2024-02-12T12:50:51 Z |
vjudge1 |
Kitchen (BOI19_kitchen) |
C++17 |
|
75 ms |
106880 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define emb emplace_back
#define emc emplace
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
template <class type_key, class type_val>
using um = unordered_map<type_key, type_val>;
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
signed main(void)
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, k;
cin >> n >> m >> k;
int a[n+1];
int tota = 0;
for( int i = 1; i <= n; i++ ) {
cin >> a[i];
tota += a[i];
if( a[i] < k ) return cout << "Impossible", 0;
}
int w[m+1], c[m+1];
int totb = 0;
for( int i = 1; i <= m; i++ ) {
int b;
cin >> b;
totb += b;
w[i] = b;
c[i] = min(n, b);
}
if( tota > totb || k > m ) return cout << "Impossible", 0;
vector<vector<int>> dp(m+1,vector<int>(90001, -INT_MAX));
for( int i = 0; i <= m; i++ ) dp[i][0] = 0;
for( int i = 1; i <= m; i++ ) {
for( int j = 1; j <= 90000; j++ ) {
dp[i][j] = dp[i-1][j];
if( j - w[i] >= 0 ) {
if( dp[i][j - w[i]] == -INT_MAX ) continue;
dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + c[i]);
}
}
}
int ans = -1;
for( int i = tota; i <= 90000; i++ ) {
if( dp[m][i] >= n*k ) {
ans = i - tota;
break;
}
}
if( ans == -1 ) cout << "Impossible";
else cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
2 ms |
1628 KB |
Output is correct |
3 |
Correct |
1 ms |
1732 KB |
Output is correct |
4 |
Correct |
1 ms |
1784 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
0 ms |
456 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
2 ms |
1628 KB |
Output is correct |
3 |
Correct |
1 ms |
1732 KB |
Output is correct |
4 |
Correct |
1 ms |
1784 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
0 ms |
456 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
5 ms |
6236 KB |
Output is correct |
10 |
Correct |
4 ms |
6236 KB |
Output is correct |
11 |
Correct |
4 ms |
6232 KB |
Output is correct |
12 |
Correct |
4 ms |
6236 KB |
Output is correct |
13 |
Correct |
4 ms |
6236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
93020 KB |
Output is correct |
2 |
Correct |
59 ms |
80792 KB |
Output is correct |
3 |
Correct |
75 ms |
106880 KB |
Output is correct |
4 |
Correct |
75 ms |
106836 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
58 ms |
74320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
15192 KB |
Output is correct |
2 |
Correct |
13 ms |
15196 KB |
Output is correct |
3 |
Correct |
13 ms |
15192 KB |
Output is correct |
4 |
Correct |
12 ms |
15196 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
2 ms |
1628 KB |
Output is correct |
3 |
Correct |
1 ms |
1732 KB |
Output is correct |
4 |
Correct |
1 ms |
1784 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
0 ms |
456 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
5 ms |
6236 KB |
Output is correct |
10 |
Correct |
4 ms |
6236 KB |
Output is correct |
11 |
Correct |
4 ms |
6232 KB |
Output is correct |
12 |
Correct |
4 ms |
6236 KB |
Output is correct |
13 |
Correct |
4 ms |
6236 KB |
Output is correct |
14 |
Correct |
66 ms |
93020 KB |
Output is correct |
15 |
Correct |
59 ms |
80792 KB |
Output is correct |
16 |
Correct |
75 ms |
106880 KB |
Output is correct |
17 |
Correct |
75 ms |
106836 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
58 ms |
74320 KB |
Output is correct |
20 |
Correct |
11 ms |
15192 KB |
Output is correct |
21 |
Correct |
13 ms |
15196 KB |
Output is correct |
22 |
Correct |
13 ms |
15192 KB |
Output is correct |
23 |
Correct |
12 ms |
15196 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
53 ms |
75092 KB |
Output is correct |
26 |
Correct |
66 ms |
86652 KB |
Output is correct |
27 |
Correct |
40 ms |
57436 KB |
Output is correct |
28 |
Correct |
63 ms |
87120 KB |
Output is correct |
29 |
Correct |
66 ms |
89428 KB |
Output is correct |
30 |
Correct |
75 ms |
106768 KB |
Output is correct |