답안 #567560

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
567560 2022-05-23T17:28:08 Z birthdaycake Kitchen (BOI19_kitchen) C++17
100 / 100
32 ms 1044 KB
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);
using namespace std;
 
 
 
 
int dp[200001],a[20001],b[200001];
 
signed main(){
    boost;
    
    
    
    
    int n,m,k,sum = 0; cin >> n >> m >>  k;
    for(int i = 0; i < n; i++){
        cin >> a[i]; sum += a[i];
    }
    for(int j = 0; j < m; j++) cin >> b[j];
    if(m < k){
        cout << "Impossible";
        return 0;
    }
    for(int i = 0; i < n; i++){
        if(a[i] < k){
            cout << "Impossible";
            return 0;
        }
    }
    for(int i = 1; i <= 90000; i++) dp[i] = -1e18;
    for(int i = 0; i < m; i++){
        for(int j = 90000; j >= b[i]; j--){
            dp[j] = max(dp[j], dp[j - b[i]] + min(b[i],n));
        }
    }
    for(int i = sum; i <= 90000; i++){
        if(dp[i] >= n * k){
            cout << i - sum;
            return 0;
        }
    }
    cout << "Impossible";
    
    
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 2 ms 980 KB Output is correct
10 Correct 2 ms 980 KB Output is correct
11 Correct 2 ms 980 KB Output is correct
12 Correct 2 ms 980 KB Output is correct
13 Correct 2 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1044 KB Output is correct
2 Correct 21 ms 980 KB Output is correct
3 Correct 32 ms 980 KB Output is correct
4 Correct 26 ms 1032 KB Output is correct
5 Correct 24 ms 968 KB Output is correct
6 Correct 18 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 980 KB Output is correct
2 Correct 4 ms 980 KB Output is correct
3 Correct 4 ms 972 KB Output is correct
4 Correct 4 ms 980 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 2 ms 980 KB Output is correct
10 Correct 2 ms 980 KB Output is correct
11 Correct 2 ms 980 KB Output is correct
12 Correct 2 ms 980 KB Output is correct
13 Correct 2 ms 980 KB Output is correct
14 Correct 22 ms 1044 KB Output is correct
15 Correct 21 ms 980 KB Output is correct
16 Correct 32 ms 980 KB Output is correct
17 Correct 26 ms 1032 KB Output is correct
18 Correct 24 ms 968 KB Output is correct
19 Correct 18 ms 980 KB Output is correct
20 Correct 4 ms 980 KB Output is correct
21 Correct 4 ms 980 KB Output is correct
22 Correct 4 ms 972 KB Output is correct
23 Correct 4 ms 980 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 17 ms 976 KB Output is correct
26 Correct 21 ms 1044 KB Output is correct
27 Correct 14 ms 980 KB Output is correct
28 Correct 20 ms 972 KB Output is correct
29 Correct 24 ms 980 KB Output is correct
30 Correct 27 ms 972 KB Output is correct