#include<bits/stdc++.h>
#define ll long long
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define endl '\n'
#define pb push_back
using namespace std ;
//fflush(stdout) ;
const int Max_n=305 ;
int a[Max_n] , b[Max_n] ;
int main(){
int n , m , k ; cin >> n >> m >> k ;
for(int i=0 ; i<n ; i++) cin >> a[i] ;
for(int i=0 ; i<m ; i++) cin >> b[i] ;
if(m<=2){
int sum_a=0 , sum_b=0 ;
for(int i=0 ; i<n ; i++) sum_a+=a[i] ;
for(int i=0 ; i<m ; i++) sum_b+=b[i] ;
if(k>m){
cout << "Impossible" ;
return 0 ;
}
if(k==m){
if(sum_a>sum_b){
cout << "Impossible" ;
return 0 ;
}
for(int i=0 ; i<n ; i++){
if(a[i]<k){
cout << "Impossible" ;
return 0 ;
}
}
for(int i=0 ; i<m ; i++){
if(b[i]<n){
cout << "Impossible" ;
return 0 ;
}
}
cout << sum_b-sum_a ;
}
else{
int ans=400 ;
if(b[0]>=sum_a) ans=b[0]-sum_a ;
if(b[1]>=sum_a) ans=min(b[0]-sum_a,ans) ;
if(ans==400){
if(sum_a>sum_b){
cout << "Impossible" ;
return 0 ;
}
cout << sum_b-sum_a ;
}
else cout << ans ;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
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 |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |