#include <bits/stdc++.h>
#define int ll
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define sz(a) (int)a.size()
#define vec(...) vector<__VA_ARGS__>
#define _3NRqilq ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
using pii=pair<int,int>;
using vi=vector<int>;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}
void chmin(int&a,int b){
a=min(a,b);
}
signed main(){
_3NRqilq;
int n,m,k;
cin>>n>>m>>k;
vi a(n);
rep(i,n){
cin>>a[i];
}
vi b(m);
rep(i,m){
cin>>b[i];
}
sort(b.begin(),b.end());
if(k>m){
cout<<"Impossible\n";
return 0;
}
assert(m==2 and k==1);
const int inf=1e9;
int ans=0;
rep(i,n){
// if(k==2){
// if(a[i]<2){
// ans+=inf;
// }else{
// ans+=b[0]+b[1]-a[i];
// }
// }else{
if(a[i]>b[1]){
cout<<"Impossible\n";
return 0;
}else if(a[i]<b[0]){
assert(0);
ans+=b[0]-a[i];
}else{
assert(0);
ans+=b[1]-a[i];
}
}
if(ans>=inf){
cout<<"Impossible\n";
}else{
cout<<ans<<"\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |