# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
134896 |
2019-07-23T11:43:53 Z |
miguel |
Kitchen (BOI19_kitchen) |
C++14 |
|
240 ms |
118684 KB |
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
#define nmax 301
const ll mod = 998244353;
int n, m, k, s;
int a[605], b[605], dp[309][100001];
int32_t main(){
ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
cin>>n>>m>>k;
if(m<k) return cout<<"Impossible", 0;
for(int i=1; i<=n; i++){
cin>>a[i];
s+=a[i];
if(a[i]<k) return cout<<"Impossible", 0;
}
for(int i=0; i<m; i++) cin>>b[i];
for(int i=0; i<=100000; i++){
for(int j=0; j<=m+1; j++) dp[j][i]=-(1<<30);
}
dp[0][0]=0;
for (int i = 0; i<m; i++) {
for (int j = 0; j <= 90000; j++) {
if (dp[i][j] == -(1 << 30)) continue;
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
dp[i + 1][j + b[i]] = max(dp[i + 1][j + b[i]], dp[i][j] + min(b[i], n));
}
}
for (int i = s; i <= 90000; i++) {
if (dp[m][i] >= n * k) return cout<<i - s, 0;
}
cout<<"Impossible";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1912 KB |
Output is correct |
2 |
Correct |
4 ms |
1912 KB |
Output is correct |
3 |
Correct |
4 ms |
1912 KB |
Output is correct |
4 |
Correct |
4 ms |
1916 KB |
Output is correct |
5 |
Correct |
4 ms |
1912 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
380 KB |
Output is correct |
8 |
Correct |
4 ms |
1912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1912 KB |
Output is correct |
2 |
Correct |
4 ms |
1912 KB |
Output is correct |
3 |
Correct |
4 ms |
1912 KB |
Output is correct |
4 |
Correct |
4 ms |
1916 KB |
Output is correct |
5 |
Correct |
4 ms |
1912 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
380 KB |
Output is correct |
8 |
Correct |
4 ms |
1912 KB |
Output is correct |
9 |
Correct |
10 ms |
7160 KB |
Output is correct |
10 |
Correct |
10 ms |
7032 KB |
Output is correct |
11 |
Correct |
10 ms |
7032 KB |
Output is correct |
12 |
Correct |
10 ms |
7036 KB |
Output is correct |
13 |
Correct |
10 ms |
7032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
103312 KB |
Output is correct |
2 |
Correct |
149 ms |
89528 KB |
Output is correct |
3 |
Correct |
220 ms |
118684 KB |
Output is correct |
4 |
Correct |
234 ms |
118520 KB |
Output is correct |
5 |
Correct |
220 ms |
114660 KB |
Output is correct |
6 |
Correct |
154 ms |
82620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
16760 KB |
Output is correct |
2 |
Correct |
26 ms |
16760 KB |
Output is correct |
3 |
Correct |
25 ms |
16760 KB |
Output is correct |
4 |
Correct |
26 ms |
16716 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1912 KB |
Output is correct |
2 |
Correct |
4 ms |
1912 KB |
Output is correct |
3 |
Correct |
4 ms |
1912 KB |
Output is correct |
4 |
Correct |
4 ms |
1916 KB |
Output is correct |
5 |
Correct |
4 ms |
1912 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
380 KB |
Output is correct |
8 |
Correct |
4 ms |
1912 KB |
Output is correct |
9 |
Correct |
10 ms |
7160 KB |
Output is correct |
10 |
Correct |
10 ms |
7032 KB |
Output is correct |
11 |
Correct |
10 ms |
7032 KB |
Output is correct |
12 |
Correct |
10 ms |
7036 KB |
Output is correct |
13 |
Correct |
10 ms |
7032 KB |
Output is correct |
14 |
Correct |
176 ms |
103312 KB |
Output is correct |
15 |
Correct |
149 ms |
89528 KB |
Output is correct |
16 |
Correct |
220 ms |
118684 KB |
Output is correct |
17 |
Correct |
234 ms |
118520 KB |
Output is correct |
18 |
Correct |
220 ms |
114660 KB |
Output is correct |
19 |
Correct |
154 ms |
82620 KB |
Output is correct |
20 |
Correct |
29 ms |
16760 KB |
Output is correct |
21 |
Correct |
26 ms |
16760 KB |
Output is correct |
22 |
Correct |
25 ms |
16760 KB |
Output is correct |
23 |
Correct |
26 ms |
16716 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
136 ms |
83320 KB |
Output is correct |
26 |
Correct |
160 ms |
96436 KB |
Output is correct |
27 |
Correct |
108 ms |
63736 KB |
Output is correct |
28 |
Correct |
178 ms |
96620 KB |
Output is correct |
29 |
Correct |
188 ms |
99064 KB |
Output is correct |
30 |
Correct |
240 ms |
118676 KB |
Output is correct |