제출 #1099422

#제출 시각아이디문제언어결과실행 시간메모리
1099422vjudge1Kitchen (BOI19_kitchen)C++17
100 / 100
21 ms1884 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout) const int maxn = 301, inf = 1e18; int n, m, k, a[maxn], b[maxn], f[2][maxn*maxn]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); fileio(""); // freopen("debug.txt", "w", stderr); cin >> n >> m >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] < k) { cout << "Impossible"; return 0; } } for (int i = 1; i <= m; i++) { cin >> b[i]; } for (int i = 1; i <= 300*300; i++) { f[0][i] = -inf; } for (int i = 1; i <= m; i++) { for (int j = 0; j <= 300*300; j++) { f[i%2][j] = f[(i-1)%2][j]; if (j >= b[i]) { f[i%2][j] = max(f[i%2][j], f[(i-1)%2][j - b[i]] + min(n, b[i])); } } } int res = inf, sum = accumulate(a+1, a+1+n, 0LL); for (int i = sum; i <= 300*300; i++) { if (f[m%2][i] >= n*k) { res = i; break; } } if (res < inf) { cout << res - sum; } else { cout << "Impossible"; } return 0 ^ 0; }

컴파일 시 표준 에러 (stderr) 메시지

kitchen.cpp: In function 'int32_t main()':
kitchen.cpp:5:57: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout)
      |                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:13:5: note: in expansion of macro 'fileio'
   13 |     fileio("");
      |     ^~~~~~
kitchen.cpp:5:90: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout)
      |                                                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:13:5: note: in expansion of macro 'fileio'
   13 |     fileio("");
      |     ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...