# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
493007 |
2021-12-10T02:20:05 Z |
wiwiho |
Kitchen (BOI19_kitchen) |
C++14 |
|
1 ms |
460 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void nosol(){
cout << "Impossible\n";
exit(0);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cerr.tie(0);
int n, m, k;
cin >> n >> m >> k;
vector<int> a(n + 1);
vector<int> b(m + 1);
ll sa = 0, sb = 0;
for(int i = 1; i <= n; i++) cin >> a[i], sa += a[i];
for(int i = 1; i <= m; i++) cin >> b[i], sb += b[i];
sort(b.begin() + 1, b.end());
if(k > m || sa > sb){
nosol();
}
for(int i = 1; i <= n; i++) if(a[i] < k) nosol();
assert(m <= 2);
if(k == 1){
if(sa <= b[1]) cout << b[1] - sa << "\n";
else if(sa <= b[2]) cout << b[2] - sa << "\n";
else cout << b[1] + b[2] - sa << "\n";
return 0;
}
if(n > b[1]) nosol();
cout << b[1] + b[2] - sa << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
10 |
Halted |
0 ms |
0 KB |
- |