# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1028185 | 2024-07-19T14:57:15 Z | hasan2006 | Kitchen (BOI19_kitchen) | C++17 | 15 ms | 1260 KB |
#include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 1e5 + 9 , mod = 1e9 + 7; ll dp[N] , a[N] , b[N]; void solve() { ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ; cin>>n>>m>>k; for(i = 1; i <= n; i++){ cin>>a[i]; s += a[i]; } for(i = 1; i <= m;i++) cin>>b[i]; sort(b + 1 , b + m + 1); dp[0] = 0; x = 1e5; fill(dp + 1, dp + x + 1 , -1e15); if(b[1] < k || k > m){ cout<<"Impossible"; return; } for(i = 1; i <= m;i++) for(j = x; j >= b[i]; j--) dp[j] = max(dp[j] , dp[j - b[i]] + min(n , b[i])); for(i = s; i <= x; i++) if(dp[i] >= n * k){ cout<<i - s<<"\n"; return; } cout<<"Impossible"; } int main(){ TL; /*#ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif*/ int t = 1; // cin>>t; while(t--) { solve(); } } // Author : حسن
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1116 KB | Output is correct |
2 | Correct | 1 ms | 1236 KB | Output is correct |
3 | Correct | 1 ms | 1160 KB | Output is correct |
4 | Correct | 0 ms | 1116 KB | Output is correct |
5 | Correct | 0 ms | 1116 KB | Output is correct |
6 | Correct | 1 ms | 1228 KB | Output is correct |
7 | Incorrect | 0 ms | 1116 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1116 KB | Output is correct |
2 | Correct | 1 ms | 1236 KB | Output is correct |
3 | Correct | 1 ms | 1160 KB | Output is correct |
4 | Correct | 0 ms | 1116 KB | Output is correct |
5 | Correct | 0 ms | 1116 KB | Output is correct |
6 | Correct | 1 ms | 1228 KB | Output is correct |
7 | Incorrect | 0 ms | 1116 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 1116 KB | Output is correct |
2 | Correct | 12 ms | 1260 KB | Output is correct |
3 | Correct | 15 ms | 1116 KB | Output is correct |
4 | Correct | 15 ms | 1116 KB | Output is correct |
5 | Correct | 15 ms | 1260 KB | Output is correct |
6 | Correct | 11 ms | 1116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 1116 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1116 KB | Output is correct |
2 | Correct | 1 ms | 1236 KB | Output is correct |
3 | Correct | 1 ms | 1160 KB | Output is correct |
4 | Correct | 0 ms | 1116 KB | Output is correct |
5 | Correct | 0 ms | 1116 KB | Output is correct |
6 | Correct | 1 ms | 1228 KB | Output is correct |
7 | Incorrect | 0 ms | 1116 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |