제출 #1209415

#제출 시각아이디문제언어결과실행 시간메모리
1209415Theo830Kitchen (BOI19_kitchen)C++20
0 / 100
1 ms328 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training int main(void){ ll n,m,k; cin>>n>>m>>k; ll a[n]; ll ans = 0; f(i,0,n){ cin>>a[i]; ans -= a[i]; } ll b[m]; ll posa = 0; f(i,0,m){ cin>>b[i]; ans += b[i]; posa += min(n,b[i]); } bool ok = 1; set<ii>ex; f(i,0,n){ if(a[i] < k){ ok = 0; } ex.insert(ii(k,i)); } if(ans < 0){ ok = 0; } f(j,0,m){ set<ii>vale; f(u,0,min(n,b[j])){ if(ex.empty()){ break; } auto it = ex.rbegin(); ii e = (*it); ex.erase(e); e.F--; if(e.F){ vale.insert(e); } } for(auto x:vale){ ex.insert(x); } } ok &= ex.empty(); if(ok){ cout<<ans<<"\n"; } else{ cout<<"Impossible\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...