#include<bits/stdc++.h>
#define task "strdel"
#define ii pair<int,int>
#define iii pair<int,ii>
#define iv pair<ii,ii>
#define se second
#define fi first
#define ffi fi.fi
#define sfi se.fi
#define sse se.se
#define fse fi.se
#define lt(i, c, d) for(int i = c; i <= d; ++i)
#define fl(i, c, d) for(int i = d; i >= c; --i)
#define pb push_back
#define emb emplace_back
#define emf emplace_front
#define em emplace
using namespace std;
const int N=3e2+5,lg=20,mod=1e9+7;
int a[N],m,n,k,ans,b[N];
main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> m >> k;
multiset<int>s;
for(int i=1;i<=n;++i){
cin >> a[i];
if(a[i]<k){
cout <<"impossible";
return 0;
}
}
for(int i=1;i<=m;++i){
cin >> b[i];
s.insert(b[i]);
}
for(int i=1;i<=n;++i){
int k1=k,u=a[i]/k,x=a[i]%k;
if(s.size()<k){
cout <<"impossible";return 0;
}
while(k1--){
int it=*s.rbegin();
if(it<u+(x>0)){
cout <<"impossible";return 0;
}
s.erase(s.find(it));
it-=u+(x>0);
if(it>0)
s.insert(it);
if(x>0){
--x;
}
}
a[i]=0;
}
for(int i=1;i<=n;++i){
if(a[i]>0){
cout <<"impossible";return 0;
}
}
for(int i:s)ans+=i;
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
kitchen.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
22 | main()
| ^~~~
# | 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... |