이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
//Types
using ll = long long;
using db = double;
//Vectors
#define pb push_back
#define sz(vec) ((ll)vec.size())
#define all(vec) vec.begin(), vec.end()
//things
#define f first
#define s second
const int SMALLINF = 1e9 + 7;
const ll BIGINF = ((ll)1e18) + 7;
#define Speeed ios::sync_with_stdio(0);cin.tie(NULL); cout.tie(NULL);
void solve(){
ll n, m, k, sum = 0, sum2 = 0;
cin>>n>>m>>k;
bool imp = false;
if(m<k)imp = true;
vector<ll> vec(n), hr(m);
for(ll i = 0; i < n; i++){
cin>>vec[i];
sum+=vec[i];
if(vec[i]<k)imp = true;
}
for(ll i = 0; i < m; i++){
cin>>hr[i];
sum2+=hr[i];
}
if(sum>sum2)imp = true;
// 5 5 5
//
// 14 1
if(m==2){
if(hr[0]<n or hr[1]<n)imp = true;
}
if(!imp){
if(m==2)cout<<(hr[0] + hr[1]) - sum;
else{
if(k==1){
cout<<sum2 - sum;
}
}
}
else cout<<"Impossible";
}
int main(){
Speeed
ll t=1;
// cin>>t;
while(t--){
solve();
}
}
# | 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... |