답안 #464302

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464302 2021-08-12T19:43:09 Z JovanB Kitchen (BOI19_kitchen) C++17
100 / 100
29 ms 1044 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;

const int N = 300;

int a[N+5];
int dp[N*N+5];
int mxm[N*N+5];

const int INF = 1000000000;

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, m, k;
    int tot = 0;
    cin >> n >> m >> k;
    for(int i=1; i<=n; i++){
        cin >> a[i];
        tot += a[i];
        if(a[i] < k){
            cout << "Impossible\n";
            return 0;
        }
    }
    vector <int> small, large;
    for(int i=1; i<=m; i++){
        int x;
        cin >> x;
        if(x >= n) large.push_back(x);
        else small.push_back(x);
    }
    for(auto x : small) for(int i=N*N; i>=x; i--) if(dp[i-x] == i - x) dp[i] = i;
    dp[N*N+1] = INF;
    for(int i=N*N; i>=1; i--) if(dp[i] != i) dp[i] = dp[i+1];
    for(int i=1; i<=N*N+1; i++) mxm[i] = -INF;
    for(auto x : large) for(int i=N*N; i>=x; i--) mxm[i] = max(mxm[i], mxm[i-x] + 1);
    int res = INF;
    for(int i=0; i<=N*N; i++) if(mxm[i] >= 0) res = min(res, i + dp[max(tot - i, n*max(0, k - mxm[i]))]);
    if(res == INF) cout << "Impossible\n";
    else cout << res - tot << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 972 KB Output is correct
2 Correct 2 ms 972 KB Output is correct
3 Correct 2 ms 972 KB Output is correct
4 Correct 2 ms 972 KB Output is correct
5 Correct 2 ms 972 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 972 KB Output is correct
2 Correct 2 ms 972 KB Output is correct
3 Correct 2 ms 972 KB Output is correct
4 Correct 2 ms 972 KB Output is correct
5 Correct 2 ms 972 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
9 Correct 3 ms 972 KB Output is correct
10 Correct 3 ms 972 KB Output is correct
11 Correct 3 ms 972 KB Output is correct
12 Correct 3 ms 972 KB Output is correct
13 Correct 3 ms 972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 972 KB Output is correct
2 Correct 23 ms 980 KB Output is correct
3 Correct 29 ms 1004 KB Output is correct
4 Correct 28 ms 992 KB Output is correct
5 Correct 27 ms 984 KB Output is correct
6 Correct 22 ms 952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 972 KB Output is correct
2 Correct 5 ms 1044 KB Output is correct
3 Correct 5 ms 972 KB Output is correct
4 Correct 5 ms 972 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 972 KB Output is correct
2 Correct 2 ms 972 KB Output is correct
3 Correct 2 ms 972 KB Output is correct
4 Correct 2 ms 972 KB Output is correct
5 Correct 2 ms 972 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
9 Correct 3 ms 972 KB Output is correct
10 Correct 3 ms 972 KB Output is correct
11 Correct 3 ms 972 KB Output is correct
12 Correct 3 ms 972 KB Output is correct
13 Correct 3 ms 972 KB Output is correct
14 Correct 26 ms 972 KB Output is correct
15 Correct 23 ms 980 KB Output is correct
16 Correct 29 ms 1004 KB Output is correct
17 Correct 28 ms 992 KB Output is correct
18 Correct 27 ms 984 KB Output is correct
19 Correct 22 ms 952 KB Output is correct
20 Correct 5 ms 972 KB Output is correct
21 Correct 5 ms 1044 KB Output is correct
22 Correct 5 ms 972 KB Output is correct
23 Correct 5 ms 972 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 19 ms 1028 KB Output is correct
26 Correct 24 ms 972 KB Output is correct
27 Correct 16 ms 1020 KB Output is correct
28 Correct 23 ms 1016 KB Output is correct
29 Correct 23 ms 1020 KB Output is correct
30 Correct 28 ms 972 KB Output is correct