답안 #1095576

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1095576 2024-10-02T15:05:45 Z MateiKing80 Kitchen (BOI19_kitchen) C++14
100 / 100
17 ms 1176 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 300 * 301;
int n, m, k, dp[N + 5], a[300], b[300], sum = 0;
int ldr[N + 5];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> k;
    int minn = 1e9;
    for(int i = 0; i < n; i ++)
    {
        cin >> a[i];
        ldr[a[i]] ++;
        sum += a[i];
        minn = min(minn, a[i]);
    }
    if(minn < k)
    {
        for(int i = 0; i < m; i ++)
            cin >> n;
        cout << "Impossible";
        return 0;
    }
    for(int i = N; i >= 0; i --)
        ldr[i] += ldr[i + 1];
    for(int i = 1; i <= N; i ++)
        dp[i] = -1e9;
    for(int i = 0; i < m; i ++)
    {
        cin >> b[i];
        for(int j = N; j >= b[i]; j --)
            dp[j] = max(dp[j], min(b[i], n) + dp[j - b[i]]);
    }
    for(int i = sum; i <= 300 * 301; i ++)
        if (dp[i] >= n * k)
        {
            cout << i - sum;
            return 0;
        }
    cout << "Impossible";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 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 980 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 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 980 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 2 ms 1112 KB Output is correct
10 Correct 1 ms 1112 KB Output is correct
11 Correct 2 ms 1112 KB Output is correct
12 Correct 1 ms 1112 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1116 KB Output is correct
2 Correct 13 ms 1116 KB Output is correct
3 Correct 16 ms 1116 KB Output is correct
4 Correct 16 ms 1116 KB Output is correct
5 Correct 16 ms 1116 KB Output is correct
6 Correct 12 ms 1012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1116 KB Output is correct
2 Correct 3 ms 1116 KB Output is correct
3 Correct 3 ms 1116 KB Output is correct
4 Correct 3 ms 1116 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 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 980 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 2 ms 1112 KB Output is correct
10 Correct 1 ms 1112 KB Output is correct
11 Correct 2 ms 1112 KB Output is correct
12 Correct 1 ms 1112 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 15 ms 1116 KB Output is correct
15 Correct 13 ms 1116 KB Output is correct
16 Correct 16 ms 1116 KB Output is correct
17 Correct 16 ms 1116 KB Output is correct
18 Correct 16 ms 1116 KB Output is correct
19 Correct 12 ms 1012 KB Output is correct
20 Correct 3 ms 1116 KB Output is correct
21 Correct 3 ms 1116 KB Output is correct
22 Correct 3 ms 1116 KB Output is correct
23 Correct 3 ms 1116 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 12 ms 976 KB Output is correct
26 Correct 13 ms 1168 KB Output is correct
27 Correct 9 ms 1112 KB Output is correct
28 Correct 14 ms 1116 KB Output is correct
29 Correct 14 ms 1116 KB Output is correct
30 Correct 17 ms 1176 KB Output is correct