Submission #826477

#TimeUsernameProblemLanguageResultExecution timeMemory
826477Chal1shkanA Difficult(y) Choice (BOI21_books)C++14
0 / 100
1 ms336 KiB
//Bismillahir-Rahmanir-Rahim

# include <bits/stdc++.h>
# include <books.h>

# define pb push_back
# define ff first
# define ss second
# define nl "\n"
# define sz(x) ((int)(x).size())
# define all(x) (x).begin(), (x).end()
# define deb(x) cerr << #x  << " = " << x << endl; 
# define pll pair <ll, ll>
# define pii pair <int, int>
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const ll maxn = 1e5 + 7;
const ll inf = 2e18 + 0;
const ll mod = 1e9 + 7;
const ll dx[] = {-1, 1, 0, 0};
const ll dy[] = {0, 0, -1, 1};

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll arr[maxn];
ll pref[maxn];

ll get (ll x) {
	if (!arr[x]) {
		arr[x] = skim(x);
	}
	return arr[x];
}

void solve(int N, int K, long long A, int S) {
	ll sum = 0;
	for (ll i = 1; i <= K; ++i) {
		sum += get(i);
	}
	for (ll i = K; i >= 1; --i) {
		ll cur = sum - arr[i];
		ll l = K + 1, r = N, pos = -1;
		while (l <= r) {
			ll mid = (l + r) >> 1;
			if (get(mid) + cur <= 2 * A) {
				l = mid + 1;
				pos = mid;
			}
			else {
				r = mid - 1;
			}
		}
		if (pos != -1) {
			if (A <= cur + get(pos) && cur + get(pos) <= 2 * A) {
				vector <int> ans;
				for (ll j = 1; j <= K; ++j) {
					if (j != i) {
						ans.pb(j);
					}
				}
				ans.pb(pos);
				answer(ans);
				exit(0);
			}
		}
	}
	impossible();
}
#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...