Submission #735042

#TimeUsernameProblemLanguageResultExecution timeMemory
735042baokhue232005A Difficult(y) Choice (BOI21_books)C++14
100 / 100
1 ms364 KiB
#include"books.h" #include<bits/stdc++.h> using namespace std; vector<int> sax; #define all(flg) flg.begin(), flg.end() #define int long long #define pb push_back #define fi first #define se second #define endl "\n" #define eb emplace_back #define ii pair<int, int> #define vi vector<int> #define PI 3.141592653589793238462643383279502884 #define ll long long #define ld long double #define for1(i, ff, gg) for(int i = ff; i <= gg; ++i) #define for2(i, ff, gg) for(int i = ff; i >= gg; --i) const ll mod = 1e9 + 7; const int maxN = 3e5 + 5; const ll oo = 1e18 + 7; int n, a[maxN]; int x, y, z, k; int dbl; vi res, ser; int sum = 0; bool pout(){ // cout << sum << " " << dbl << " " << 2 * dbl << endl; if(sum >= dbl && sum <= 2 * dbl){ vi ans; for(int cc : ser) ans.pb(cc); for(int cc : res) ans.pb(cc); for(int cc : ans) sax.pb(cc); answer(sax); return 1; } return 0; } #undef int void solve(int nigga, int kigga, ll apezite, int wojafacke){ #define int long long n = nigga; k = kigga; dbl = apezite; if(k > n) impossible(); for1(i, 1, k - 1){ a[i] = skim(i); sum += a[i]; res.pb(i); } int l = k, r = n; while(l != r){ int mid = (l + r + 1) / 2; int val = skim(mid); if(sum + val <= dbl * 2) l = mid; else r = mid - 1; } // cout << l << endl; for1(dumb, 1, k){ a[l] = skim(l); sum += a[l]; ser.pb(l); if(pout()) return; if(res.size()){ sum -= a[res.back()]; res.pop_back(); } --l; } impossible(); #undef int }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...