이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N, M, K;
cin >> N >> M >> K;
vector<int> recipes(N), chefs(M);
for (int &i : recipes)
cin >> i;
for (int &i : chefs)
cin >> i;
int totalwork = accumulate(recipes.begin(), recipes.end(), 0);
int totalchefs = accumulate(chefs.begin(), chefs.end(), 0);
if (K > M || totalchefs < totalwork)
cout << "Impossible\n";
else if (M == 1 && K == 1)
cout << chefs[0] - totalwork;
else if (M == 2 && K == 1)
{
if (min(chefs[0], chefs[1]) >= totalwork)
cout << min(chefs[0], chefs[1]) - totalwork;
else if (max(chefs[0], chefs[1]) >= totalwork)
cout << max(chefs[0], chefs[1]) - totalwork;
else
cout << chefs[0]+chefs[1] - totalwork;
}
else if (M == 2 && K == 2)
{
if (min(chefs[0], chefs[1]) < N)
cout << "Impossible\n";
else
cout << chefs[0]+chefs[1] - totalwork;
}
else
assert(false);
}
# | 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... |