답안 #161846

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
161846 2019-11-04T17:16:48 Z karma Kitchen (BOI19_kitchen) C++14
100 / 100
240 ms 113784 KB
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

const int N = 307;
const int Sum = N * N;

int f[Sum][N], s, a[N], b[N], sum, n, m, k;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> m >> k;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i], s += a[i];
        if(a[i] < k) return cout << "Impossible", 0;
    }
    for(int j = 1; j <= m; ++j) cin >> b[j], sum += b[j];
    memset(&f, -1, sizeof f);
    for(int i = 0; i <= m; ++i) f[0][i] = 0;
    for(int i = 1; i <= sum; ++i) {
        for(int j = 1; j <= m; ++j) {
           if(i - b[j] >= 0 && f[i - b[j]][j - 1] != -1)
            f[i][j] = f[i - b[j]][j - 1] + min(n, b[j]);
        }
        for(int j = 1; j <= m; ++j) f[i][j] = max(f[i][j - 1], f[i][j]);
    }
    for(int i = s; i <= sum; ++i) {
        if(f[i][m] >= k * n) return cout << i - s, 0;
    }
    cout << "Impossible";
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(Task".inp", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(Task".out", "w", stdout);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 107 ms 113576 KB Output is correct
2 Correct 100 ms 113512 KB Output is correct
3 Correct 97 ms 113680 KB Output is correct
4 Correct 97 ms 113656 KB Output is correct
5 Correct 100 ms 113528 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 99 ms 113656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 107 ms 113576 KB Output is correct
2 Correct 100 ms 113512 KB Output is correct
3 Correct 97 ms 113680 KB Output is correct
4 Correct 97 ms 113656 KB Output is correct
5 Correct 100 ms 113528 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 99 ms 113656 KB Output is correct
9 Correct 103 ms 113576 KB Output is correct
10 Correct 98 ms 113640 KB Output is correct
11 Correct 98 ms 113656 KB Output is correct
12 Correct 97 ms 113660 KB Output is correct
13 Correct 98 ms 113596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 185 ms 113784 KB Output is correct
2 Correct 177 ms 113632 KB Output is correct
3 Correct 195 ms 113636 KB Output is correct
4 Correct 238 ms 113656 KB Output is correct
5 Correct 233 ms 113660 KB Output is correct
6 Correct 154 ms 113656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 105 ms 113528 KB Output is correct
2 Correct 101 ms 113628 KB Output is correct
3 Correct 98 ms 113528 KB Output is correct
4 Correct 102 ms 113584 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 107 ms 113576 KB Output is correct
2 Correct 100 ms 113512 KB Output is correct
3 Correct 97 ms 113680 KB Output is correct
4 Correct 97 ms 113656 KB Output is correct
5 Correct 100 ms 113528 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 99 ms 113656 KB Output is correct
9 Correct 103 ms 113576 KB Output is correct
10 Correct 98 ms 113640 KB Output is correct
11 Correct 98 ms 113656 KB Output is correct
12 Correct 97 ms 113660 KB Output is correct
13 Correct 98 ms 113596 KB Output is correct
14 Correct 185 ms 113784 KB Output is correct
15 Correct 177 ms 113632 KB Output is correct
16 Correct 195 ms 113636 KB Output is correct
17 Correct 238 ms 113656 KB Output is correct
18 Correct 233 ms 113660 KB Output is correct
19 Correct 154 ms 113656 KB Output is correct
20 Correct 105 ms 113528 KB Output is correct
21 Correct 101 ms 113628 KB Output is correct
22 Correct 98 ms 113528 KB Output is correct
23 Correct 102 ms 113584 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 165 ms 113632 KB Output is correct
26 Correct 183 ms 113628 KB Output is correct
27 Correct 127 ms 113672 KB Output is correct
28 Correct 173 ms 113528 KB Output is correct
29 Correct 200 ms 113652 KB Output is correct
30 Correct 240 ms 113528 KB Output is correct