제출 #735037

#제출 시각아이디문제언어결과실행 시간메모리
735037baokhue232005A Difficult(y) Choice (BOI21_books)C++14
0 / 100
1 ms208 KiB
/* #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("unroll-loops") */ // lethal option #include"books.h" #include<bits/stdc++.h> using namespace std; #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; void answer(vi soke){ for(int cc : soke) cout << cc << " "; cout << endl; } bool pout(){ if(sum >= dbl && sum <= 2 * dbl){ vi ans; for(int cc : ser) ans.pb(cc); for(int cc : res) ans.pb(cc); answer(ans); 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(); int sum = 0; 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; } for2(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...