#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll mod = 1e9 + 7;
int main(){
int n, m, k;
cin >> n >> m >> k;
vector<ll> v(n), t(m);
for(auto& i : v){
cin >> i;
}
for(auto& i : t){
cin >> i;
}
if(m < k){
cout << "impossible" << endl;
return 0;
}
int sumv = 0;
for(auto& i : v){
sumv += i;
}
int sumt = 0;
for(auto& i : t){
sumt += i;
}
if(sumt < sumv){
cout << "impossible" << endl;
return 0;
}
if(m == k){
cout << sumt - sumv << endl;
return 0;
}
else{
int lossa = t[0] - sumv, lossb = t[1] - sumv;
if(lossa > 0 && lossb > 0){
cout << min(lossa, lossb) << endl;
return 0;
}
if(lossa > 0){
cout << lossa << endl;
return 0;
}
if(lossb > 0){
cout << lossb << endl;
return 0;
}
else{
cout << sumt - sumv << endl;
return 0;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Incorrect |
0 ms |
304 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Incorrect |
0 ms |
304 KB |
Output isn't correct |
7 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Incorrect |
0 ms |
304 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |