이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int inf = 1e18;
int n, m, k, res;
int s1, s2, s3, s4, s5, s6, s7, l;
int dp[100001];
int b[301];
signed main(){
    cin >> n >> m >> k;
    s7 = inf;
    for(int i = 1; i <= n; i++){
        cin >> l;
        s2 += l;
        s7 = min(s7, l);
    }
    for(int i = 1; i <= m; i++){
        cin >> b[i];
        s4 += b[i];
    }
    for(int i = 0; i <= s4; i++)
        dp[i] = -inf;
    if(s7 < k){
        cout << "Imposible";
        exit(0);
    }
    dp[0] = 0;
    for(int i = 1; i <= m; i++){
        for(int j = s4 - b[j]; j >= 0; --j){
            if(dp[j] != inf){
                dp[j + b[i]] = max(dp[j + b[i]], dp[j] + min(b[i], n));
            }
            s3 = inf;
            for(int j = s2; j <= s4; j++){
                if(dp[j] >= n * k) s3 = min(s3, j - s2);
            }
        }
    }
    if(s3 != inf) cout << s3;
    else cout << "Impossible";
}
컴파일 시 표준 에러 (stderr) 메시지
kitchen.cpp: In function 'int main()':
kitchen.cpp:29:29: warning: array subscript -1 is below array bounds of 'long long int [301]' [-Warray-bounds]
   29 |         for(int j = s4 - b[j]; j >= 0; --j){
      |                          ~~~^
kitchen.cpp:8:5: note: while referencing 'b'
    8 | int b[301];
      |     ^| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |