답안 #746051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
746051 2023-05-21T10:51:12 Z vjudge1 Kitchen (BOI19_kitchen) C++11
72 / 100
35 ms 644 KB
#include <bits/stdc++.h>

using namespace std;

int n,m,k;
int a[301];
int b[301];
int sum=0;
int w=320;

void subtask3() {
    vector<bool> g;
    vector<int> krit;
    g.assign(sum+1+w+w,0);
    krit.assign(sum+1+w+w,0);
    g[w]=1;
    for (int i=1;i<=m;i++) {
        for (int j=min(i*w,sum+w);j>max(0,sum-(m-i)*w-w);j--) {
            if (g[j+w-b[i]]==1) {
                g[j+w]=1;
                krit[j+w]=max(krit[j+w],krit[j+w-b[i]]+min(b[i],n));
            }
        }
    }
    int ans=-1;
    for (int i=sum+w;i<sum+w+w;i++) {
        if (g[i] && (krit[i]>=n*k)) {
            ans=i-w;
            break;
        }
    }
    /*
    for (int i=0;i<g.size();i++) {
        cout << i << ": " << g[i] << endl;
    }
    cout << endl;
    */
    if (ans==-1) {
        cout << "Impossible" << endl;
    } else {
        cout << ans-sum << endl;
    }
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> k;
    for (int i=1;i<=n;i++) {
        cin >> a[i];
        sum+=a[i];
    }
    for (int i=1;i<=m;i++) {
        cin >> b[i];
    }
    for (int i=1;i<=n;i++) {
        if (a[i]<k) {
            cout << "Impossible" << endl;
            return(0);
        }
    }
    subtask3();
    return 0;
}

/*
1 8 1
100
12 56 8 23 6 4 59 163
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 544 KB Output is correct
2 Correct 8 ms 468 KB Output is correct
3 Correct 35 ms 468 KB Output is correct
4 Correct 27 ms 644 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 7 ms 540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 15 ms 544 KB Output is correct
15 Correct 8 ms 468 KB Output is correct
16 Correct 35 ms 468 KB Output is correct
17 Correct 27 ms 644 KB Output is correct
18 Correct 3 ms 596 KB Output is correct
19 Correct 7 ms 540 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Incorrect 6 ms 468 KB Output isn't correct
26 Halted 0 ms 0 KB -