This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
int n, m, k, ans=0,flag=1, ans2=0; cin>>n>>m>>k;
vector<int> a(n), b(m), c(n);
for(int i=0; i<n; i++) cin>>a[i], c[i]=a[i];
for(int i=0; i<m; i++) cin>>b[i];
for(int i=0; i<m; i++)
{
for(int l=0; l<n; l++)
{
if(a[l]>c[l]-k&&b[i]>0) b[i]--, a[l]--;
if(a[l]<0) flag=0;
}
ans+=b[i];
}
for(int i=0; i<n; i++)
{
if(a[i]!=c[i]-k) flag=0;
ans2+=a[i];
}
if(ans2>ans) flag=0;
if(flag) cout<<ans-ans2;
else cout<<"Impossible";
}
# | 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... |