# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
926090 |
2024-02-12T14:43:08 Z |
vjudge1 |
Kitchen (BOI19_kitchen) |
C++17 |
|
28 ms |
23456 KB |
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
#define pb push_back
#define vt vector
#define endl '\n'
typedef long long ll;
const ll mod=1e9+7;
const ll inf=mod;
const int N=5e6+4;
int n,m,k,a[N],b[N];
int dp[N];
void solve(){
cin>>n>>m>>k;
int sum=0;
for(int i=0; i<N; ++i) dp[i]=-mod;
for(int i=1; i<=n; ++i){
cin>>a[i];
sum+=a[i];
if(a[i]<k){
cout<<"Impossible\n";
return;
}
}
for(int i=1; i<=m; ++i){
cin>>b[i];
}
dp[0]=0;
for(int i=1; i<=m; ++i){
for(int j=90002; j>=b[i]; --j){
dp[j]=max(dp[j-b[i]]+min(b[i],n),dp[j]);
}
}
int ans=mod;
for(int i=sum; i<=90002; ++i){
if(dp[i]>=n*k){
cout<<i-sum<<endl;
return;
}
}
cout<<"Impossible\n";
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int tt=1;
// cin>>tt;
while(tt--) {
solve();
}
}
Compilation message
kitchen.cpp: In function 'void solve()':
kitchen.cpp:39:6: warning: unused variable 'ans' [-Wunused-variable]
39 | int ans=mod;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
23128 KB |
Output is correct |
2 |
Correct |
6 ms |
23132 KB |
Output is correct |
3 |
Correct |
7 ms |
23132 KB |
Output is correct |
4 |
Correct |
7 ms |
22992 KB |
Output is correct |
5 |
Correct |
6 ms |
23132 KB |
Output is correct |
6 |
Correct |
6 ms |
23176 KB |
Output is correct |
7 |
Correct |
6 ms |
23132 KB |
Output is correct |
8 |
Correct |
6 ms |
23132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
23128 KB |
Output is correct |
2 |
Correct |
6 ms |
23132 KB |
Output is correct |
3 |
Correct |
7 ms |
23132 KB |
Output is correct |
4 |
Correct |
7 ms |
22992 KB |
Output is correct |
5 |
Correct |
6 ms |
23132 KB |
Output is correct |
6 |
Correct |
6 ms |
23176 KB |
Output is correct |
7 |
Correct |
6 ms |
23132 KB |
Output is correct |
8 |
Correct |
6 ms |
23132 KB |
Output is correct |
9 |
Correct |
10 ms |
23132 KB |
Output is correct |
10 |
Correct |
7 ms |
23132 KB |
Output is correct |
11 |
Correct |
9 ms |
23128 KB |
Output is correct |
12 |
Correct |
7 ms |
23128 KB |
Output is correct |
13 |
Correct |
7 ms |
23132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
23388 KB |
Output is correct |
2 |
Correct |
20 ms |
23132 KB |
Output is correct |
3 |
Correct |
26 ms |
23132 KB |
Output is correct |
4 |
Correct |
28 ms |
23132 KB |
Output is correct |
5 |
Correct |
25 ms |
23128 KB |
Output is correct |
6 |
Correct |
20 ms |
23132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
23132 KB |
Output is correct |
2 |
Correct |
8 ms |
23384 KB |
Output is correct |
3 |
Correct |
8 ms |
23220 KB |
Output is correct |
4 |
Correct |
9 ms |
23128 KB |
Output is correct |
5 |
Correct |
6 ms |
23132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
23128 KB |
Output is correct |
2 |
Correct |
6 ms |
23132 KB |
Output is correct |
3 |
Correct |
7 ms |
23132 KB |
Output is correct |
4 |
Correct |
7 ms |
22992 KB |
Output is correct |
5 |
Correct |
6 ms |
23132 KB |
Output is correct |
6 |
Correct |
6 ms |
23176 KB |
Output is correct |
7 |
Correct |
6 ms |
23132 KB |
Output is correct |
8 |
Correct |
6 ms |
23132 KB |
Output is correct |
9 |
Correct |
10 ms |
23132 KB |
Output is correct |
10 |
Correct |
7 ms |
23132 KB |
Output is correct |
11 |
Correct |
9 ms |
23128 KB |
Output is correct |
12 |
Correct |
7 ms |
23128 KB |
Output is correct |
13 |
Correct |
7 ms |
23132 KB |
Output is correct |
14 |
Correct |
25 ms |
23388 KB |
Output is correct |
15 |
Correct |
20 ms |
23132 KB |
Output is correct |
16 |
Correct |
26 ms |
23132 KB |
Output is correct |
17 |
Correct |
28 ms |
23132 KB |
Output is correct |
18 |
Correct |
25 ms |
23128 KB |
Output is correct |
19 |
Correct |
20 ms |
23132 KB |
Output is correct |
20 |
Correct |
9 ms |
23132 KB |
Output is correct |
21 |
Correct |
8 ms |
23384 KB |
Output is correct |
22 |
Correct |
8 ms |
23220 KB |
Output is correct |
23 |
Correct |
9 ms |
23128 KB |
Output is correct |
24 |
Correct |
6 ms |
23132 KB |
Output is correct |
25 |
Correct |
19 ms |
23216 KB |
Output is correct |
26 |
Correct |
22 ms |
23132 KB |
Output is correct |
27 |
Correct |
16 ms |
23216 KB |
Output is correct |
28 |
Correct |
22 ms |
22996 KB |
Output is correct |
29 |
Correct |
22 ms |
23456 KB |
Output is correct |
30 |
Correct |
25 ms |
23132 KB |
Output is correct |