# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1028189 | 2024-07-19T14:59:07 Z | hasan2006 | Kitchen (BOI19_kitchen) | C++17 | 19 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(a + 1 , a + n + 1); dp[0] = 0; x = 1e5; fill(dp + 1, dp + x + 1 , -1e15); if(a[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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1112 KB | Output is correct |
2 | Correct | 1 ms | 1116 KB | Output is correct |
3 | Correct | 1 ms | 1116 KB | Output is correct |
4 | Correct | 1 ms | 1116 KB | Output is correct |
5 | Correct | 1 ms | 1116 KB | Output is correct |
6 | Correct | 0 ms | 1116 KB | Output is correct |
7 | Correct | 1 ms | 1116 KB | Output is correct |
8 | Correct | 1 ms | 1116 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1112 KB | Output is correct |
2 | Correct | 1 ms | 1116 KB | Output is correct |
3 | Correct | 1 ms | 1116 KB | Output is correct |
4 | Correct | 1 ms | 1116 KB | Output is correct |
5 | Correct | 1 ms | 1116 KB | Output is correct |
6 | Correct | 0 ms | 1116 KB | Output is correct |
7 | Correct | 1 ms | 1116 KB | Output is correct |
8 | Correct | 1 ms | 1116 KB | Output is correct |
9 | Correct | 2 ms | 1116 KB | Output is correct |
10 | Correct | 1 ms | 1116 KB | Output is correct |
11 | Correct | 1 ms | 1116 KB | Output is correct |
12 | Correct | 1 ms | 1144 KB | Output is correct |
13 | Correct | 2 ms | 1116 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 1116 KB | Output is correct |
2 | Correct | 14 ms | 1248 KB | Output is correct |
3 | Correct | 19 ms | 1256 KB | Output is correct |
4 | Correct | 18 ms | 1116 KB | Output is correct |
5 | Correct | 18 ms | 1116 KB | Output is correct |
6 | Correct | 13 ms | 1116 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1116 KB | Output is correct |
2 | Correct | 3 ms | 1140 KB | Output is correct |
3 | Correct | 3 ms | 1116 KB | Output is correct |
4 | Correct | 3 ms | 1116 KB | Output is correct |
5 | Correct | 1 ms | 1116 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1112 KB | Output is correct |
2 | Correct | 1 ms | 1116 KB | Output is correct |
3 | Correct | 1 ms | 1116 KB | Output is correct |
4 | Correct | 1 ms | 1116 KB | Output is correct |
5 | Correct | 1 ms | 1116 KB | Output is correct |
6 | Correct | 0 ms | 1116 KB | Output is correct |
7 | Correct | 1 ms | 1116 KB | Output is correct |
8 | Correct | 1 ms | 1116 KB | Output is correct |
9 | Correct | 2 ms | 1116 KB | Output is correct |
10 | Correct | 1 ms | 1116 KB | Output is correct |
11 | Correct | 1 ms | 1116 KB | Output is correct |
12 | Correct | 1 ms | 1144 KB | Output is correct |
13 | Correct | 2 ms | 1116 KB | Output is correct |
14 | Correct | 16 ms | 1116 KB | Output is correct |
15 | Correct | 14 ms | 1248 KB | Output is correct |
16 | Correct | 19 ms | 1256 KB | Output is correct |
17 | Correct | 18 ms | 1116 KB | Output is correct |
18 | Correct | 18 ms | 1116 KB | Output is correct |
19 | Correct | 13 ms | 1116 KB | Output is correct |
20 | Correct | 3 ms | 1116 KB | Output is correct |
21 | Correct | 3 ms | 1140 KB | Output is correct |
22 | Correct | 3 ms | 1116 KB | Output is correct |
23 | Correct | 3 ms | 1116 KB | Output is correct |
24 | Correct | 1 ms | 1116 KB | Output is correct |
25 | Correct | 13 ms | 1116 KB | Output is correct |
26 | Correct | 15 ms | 1116 KB | Output is correct |
27 | Correct | 10 ms | 1256 KB | Output is correct |
28 | Correct | 15 ms | 1256 KB | Output is correct |
29 | Correct | 15 ms | 1116 KB | Output is correct |
30 | Correct | 18 ms | 1260 KB | Output is correct |