Submission #124858

# Submission time Handle Problem Language Result Execution time Memory
124858 2019-07-04T04:38:22 Z 박상수(#3055) Kitchen (BOI19_kitchen) C++14
0 / 100
2 ms 376 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb push_back
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N, M, K, A[310], B[310];

int main() {
    scanf("%d%d%d", &N, &M, &K);
    for(int i=1;i<=N;i++) scanf("%d", A + i);
    sort(A+1, A+1+N);
    int sa = 0; for(int i=1;i<=N;i++) sa += A[i];
    for(int i=1;i<=M;i++) scanf("%d", B + i);
    sort(B+1, B+1+M);
    auto NO = [&]() { puts("Impossible"); exit(0); };
    if(K == 1) {
        int sum = 0, chk[310] = {};
        for(int i=1;i<=N;i++) {
            int f = -1;
            for(int j=1;j<=M;j++) if(chk[j] == 0 && B[j] >= A[i]) {
                f = j; break;
            }
            if(f == -1) {
                NO();
            }
            sum += B[f];
            chk[f] = 1;
        }
        printf("%d\n", sum - sa);
    }
    return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &N, &M, &K);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:36:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=N;i++) scanf("%d", A + i);
                           ~~~~~^~~~~~~~~~~~~
kitchen.cpp:39:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=M;i++) scanf("%d", B + i);
                           ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -