답안 #745930

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
745930 2023-05-21T09:44:21 Z vjudge1 Kitchen (BOI19_kitchen) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
 
int n, m, k;
int a[301];
int b[301];
int sum = 0;
 
void st1(){
    int ans = 1e9;
    if (m < k){cout << "Impossible\n";
        return;
    }
    if (k == 1){
        for (int i = 1;i <= m;i++){
            if (b[i] >= sum) {
                ans = min(ans, b[i] - sum);
            }
        }
        int u = 0;
        for (int i = 1;i <= m; i++){
            u += b[i];
        }
        if (u >= sum) {
            ans = min(ans,u);
        }
        if (ans) cout << "Impossible\n";
        else{
            cout << ans-sum << "\n";
        }
        return;
    }else if (k == 2) {
        int u = 0;
        for (int i = 1;i <= m; i++) {
            u += b[i];
        }
        if (u >= sum) {
            ans = min(ans,u);
        }
        if (ans == 1e9)cout << "Impossible\n";
        else{
            cout << ans-sum << "\n";
        }
        return;
    }else{
        cout << "Impossible\n";
        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];
    }
    if(m <= 2) st1;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:62:16: warning: statement is a reference, not call, to function 'st1' [-Waddress]
   62 |     if(m <= 2) st1;
      |                ^~~
kitchen.cpp:62:16: warning: statement has no effect [-Wunused-value]
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -