제출 #519649

#제출 시각아이디문제언어결과실행 시간메모리
519649K4YANKitchen (BOI19_kitchen)C++17
20 / 100
14 ms1600 KiB
//Be Name Khoda #include<bits/stdc++.h> #pragma GCC optmize("Ofast,unroll-loops") #pragma GCC target ("avx2,tune=native") using namespace std; #define ll long long #define ld long double #define all(x) x.begin(), x.end() #define pii pair<int, int> #define pll pair<ll, ll> #define plll pair<pll, ll> const int mxn = 316; ll n, m, k, q, w; int mx[mxn * mxn]; vector<ll> a, b, g, f, A; vector<pll> v; bitset<mxn * mxn> dp, pd; void input() { cin >> n >> m >> k; for(int i = 0; i < n; i++) { cin >> q; a.push_back(q); w += q; } for(int i = 0; i < m; i++) { cin >> q; b.push_back(q); if(q <= n) { g.push_back(q); } else { f.push_back(q); } } } void solve() { if(m < k) { cout << "Impossible\n"; return; } for(auto u : a) { if(u < k) { cout << "Impossible\n"; return; } } dp.set(0); for(auto u : g) { dp |= (dp << u); } pd.set(0); for(auto u : f) { for(int i = mxn * mxn - 1; i > u - 1; i--) { if(pd[i - u]) { pd.set(i); mx[i] = max(mx[i - u] + 1, mx[i]); } } } for(int i = 0; i < mxn * mxn; i++) { if(pd[i]) { v.push_back({mx[i], i}); } } for(int i = 0; i < mxn * mxn; i = dp._Find_next(i)) { A.push_back(i); } A.push_back(mxn * mxn); ll ans = mxn * mxn, sum = 0, ptr; for(int i = 0; i < int(v.size()); i++) { sum = w - v[i].second; sum = max(sum, n * k - v[i].first * k); if(sum < 0) sum = 0; ptr = *lower_bound(all(A), sum); if(ptr < mxn * mxn) { sum = ptr + v[i].second; if(sum - w > -1) { ans = min(ans, sum - w); } } } if(ans == mxn * mxn) { cout << "Impossible\n"; return; } cout << ans << endl; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); input(), solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

kitchen.cpp:4: warning: ignoring '#pragma GCC optmize' [-Wunknown-pragmas]
    4 | #pragma GCC optmize("Ofast,unroll-loops")
      |
#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...