# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
942660 |
2024-03-11T02:32:12 Z |
damwuan |
Kitchen (BOI19_kitchen) |
C++14 |
|
27 ms |
856 KB |
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define bit(n,i) ((n>>i)&1)
#define all(x) x.begin(),x.end()
//#pragma GCC optimize("O2,unroll-loops")
//#pragma GCC target("avx,avx2,bmi,bmi2,sse,sse2,sse3,ssse3,sse4,popcnt")
//#define int long long
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
typedef pair<db,db> pdd;
typedef pair<ll,ll> pll;
const ll maxn=300*300;
const ll maxk=2e5+5;
const ll block_sz=317;
const ll inf=1e9;
const ll mod=111539786;
int n,m,k,a[maxn],b[maxn],sum;
int dp[300*300+1];
void sol()
{
cin >> n>>m>>k;
for1(i,1,n) cin >> a[i];
for1(i,1,m) cin >> b[i];
if (k>m)
{
cout << "Impossible";
return;
}
for1(i,1,n)
{
if (a[i]< k)
{
cout << "Impossible";
return;
}
sum+=(a[i]);
}
// return;
for1(i,0,maxn) dp[i]=-inf;
dp[0]=0;
for1(i,1,m)
{
for2(j,maxn,0)
{
if (j-b[i]>=0) dp[j]=max(dp[j],dp[j-b[i]]+min(b[i],n));
}
}
for1(i,sum,maxn)
{
if (dp[i] >= n*k)
{
cout << i-sum<<'\n';
return;
}
}
cout << "Impossible\n";
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("KITCHEN.inp","r",stdin);
// freopen("KITCHEN.out","w",stdout);
int t=1;//cin >> t;
while (t--)
{
sol();
}
}
/*
C[i-1][i+j-1]*C[sz[u]-i][sz[u]+sz[v]-i]
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 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 |
604 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
13 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
852 KB |
Output is correct |
2 |
Correct |
19 ms |
600 KB |
Output is correct |
3 |
Correct |
24 ms |
600 KB |
Output is correct |
4 |
Correct |
24 ms |
604 KB |
Output is correct |
5 |
Correct |
24 ms |
824 KB |
Output is correct |
6 |
Correct |
17 ms |
856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
604 KB |
Output is correct |
2 |
Correct |
4 ms |
604 KB |
Output is correct |
3 |
Correct |
4 ms |
816 KB |
Output is correct |
4 |
Correct |
4 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 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 |
604 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
13 |
Correct |
2 ms |
604 KB |
Output is correct |
14 |
Correct |
27 ms |
852 KB |
Output is correct |
15 |
Correct |
19 ms |
600 KB |
Output is correct |
16 |
Correct |
24 ms |
600 KB |
Output is correct |
17 |
Correct |
24 ms |
604 KB |
Output is correct |
18 |
Correct |
24 ms |
824 KB |
Output is correct |
19 |
Correct |
17 ms |
856 KB |
Output is correct |
20 |
Correct |
4 ms |
604 KB |
Output is correct |
21 |
Correct |
4 ms |
604 KB |
Output is correct |
22 |
Correct |
4 ms |
816 KB |
Output is correct |
23 |
Correct |
4 ms |
604 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
17 ms |
604 KB |
Output is correct |
26 |
Correct |
19 ms |
604 KB |
Output is correct |
27 |
Correct |
13 ms |
604 KB |
Output is correct |
28 |
Correct |
19 ms |
604 KB |
Output is correct |
29 |
Correct |
20 ms |
604 KB |
Output is correct |
30 |
Correct |
24 ms |
604 KB |
Output is correct |