# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
298432 | peuch | Kitchen (BOI19_kitchen) | C++17 | 1 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 310;
int n, m, k;
int a[MAXN], b[MAXN];
int sum;
int main(){
scanf("%d %d %d", &n, &m, &k);
for(int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
sum += a[i];
}
for(int i = 1; i <= m; i++) scanf("%d", &b[i]);
if(k > m) {
printf("Impossible\n");
return 0;
}
if(k == m && k == 2) {
if(b[1] >= n && b[2] >= n && b[1] + b[2] >= sum){
printf("%d\n", b[1] + b[2] - sum);
return 0;
}
printf("Impossible\n");
return 0;
}
else if(k == m && k == 1){
if(b[1] >= sum){
printf("%d\n", b[1] - sum);
return 0;
}
printf("Impossible\n");
return 0;
}
else if(m == k + 1){
if(b[1] >= sum && b[2] >= sum){
printf("%d", min(b[1], b[2]) - sum);
return 0;
}
else if(b[1] >= sum || b[2] >= sum){
printf("%d\n", max(b[1], b[2]) - sum);
return 0;
}
printf("Impossible\n");
return 0;
}
printf("Impossible\n");
return 0;
}
Compilation message (stderr)
# | 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... |