Submission #487670

# Submission time Handle Problem Language Result Execution time Memory
487670 2021-11-16T11:09:14 Z Koosha_mv Kitchen (BOI19_kitchen) C++14
100 / 100
37 ms 732 KB
#include <bits/stdc++.h>
using namespace std;
#define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl
#define print(v,r) f(i,0,r) cout<<v[i]<<" "; cout<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define Add(x,y) x=(x+y)%mod
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first

const int N=330;

int n,m,k,sum,dp[N*N];

int main(){
	cin>>n>>m>>k;
	f(i,0,n){
		int x;
		cin>>x;
		sum+=x;
		if(x<k) return cout<<"Impossible",0;
	}
	dp[0]=0;
	f(i,1,N*N) dp[i]=-N*N;
	f(i,0,m){
		int x;
		cin>>x;
		f_(i,N*N-1,0){
			if(i-x>=0){
				maxm(dp[i],dp[i-x]+min(n,x));
			}
		}
	}
	f(i,sum,N*N){
		if(dp[i]>=n*k){
			return cout<<i-sum,0;
		}
	}
	cout<<"Impossible";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 720 KB Output is correct
2 Correct 1 ms 720 KB Output is correct
3 Correct 1 ms 720 KB Output is correct
4 Correct 1 ms 720 KB Output is correct
5 Correct 1 ms 688 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 720 KB Output is correct
2 Correct 1 ms 720 KB Output is correct
3 Correct 1 ms 720 KB Output is correct
4 Correct 1 ms 720 KB Output is correct
5 Correct 1 ms 688 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 720 KB Output is correct
9 Correct 2 ms 720 KB Output is correct
10 Correct 2 ms 720 KB Output is correct
11 Correct 2 ms 720 KB Output is correct
12 Correct 2 ms 720 KB Output is correct
13 Correct 3 ms 720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 720 KB Output is correct
2 Correct 26 ms 720 KB Output is correct
3 Correct 33 ms 720 KB Output is correct
4 Correct 34 ms 724 KB Output is correct
5 Correct 32 ms 720 KB Output is correct
6 Correct 29 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 720 KB Output is correct
2 Correct 5 ms 724 KB Output is correct
3 Correct 5 ms 724 KB Output is correct
4 Correct 5 ms 720 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 720 KB Output is correct
2 Correct 1 ms 720 KB Output is correct
3 Correct 1 ms 720 KB Output is correct
4 Correct 1 ms 720 KB Output is correct
5 Correct 1 ms 688 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 720 KB Output is correct
9 Correct 2 ms 720 KB Output is correct
10 Correct 2 ms 720 KB Output is correct
11 Correct 2 ms 720 KB Output is correct
12 Correct 2 ms 720 KB Output is correct
13 Correct 3 ms 720 KB Output is correct
14 Correct 37 ms 720 KB Output is correct
15 Correct 26 ms 720 KB Output is correct
16 Correct 33 ms 720 KB Output is correct
17 Correct 34 ms 724 KB Output is correct
18 Correct 32 ms 720 KB Output is correct
19 Correct 29 ms 688 KB Output is correct
20 Correct 5 ms 720 KB Output is correct
21 Correct 5 ms 724 KB Output is correct
22 Correct 5 ms 724 KB Output is correct
23 Correct 5 ms 720 KB Output is correct
24 Correct 0 ms 208 KB Output is correct
25 Correct 30 ms 720 KB Output is correct
26 Correct 30 ms 720 KB Output is correct
27 Correct 19 ms 732 KB Output is correct
28 Correct 28 ms 720 KB Output is correct
29 Correct 29 ms 720 KB Output is correct
30 Correct 33 ms 592 KB Output is correct