This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include "books.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pdd pair<ld, ld>
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update> ordset;
#pragma GCC optimize("-O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-Os")
ll INF = 1e18;
ll mod = 1e9 + 7;
mt19937 gen(time(0));
void solve(int n, int k, ll a, int s){
vector<ll> arr(n);
ll sum = 0;
for(int i = 0; i < k - 1; i++){
arr[i] = skim(i + 1);
sum += arr[i];
}
int l = k, r = n - 1, ans = -1, mn = -1;
while(l <= r){
int m = (l + r) / 2;
ll u = skim(m + 1);
arr[m] = u;
if(u + sum < a){
mn = m;
l = m + 1;
}
else if(u + sum > 2ll * a) r = m - 1;
else {
ans = m;
break;
}
}
if(ans != -1) {
vector<int> res;
for(int i = 1; i < k; i++) res.push_back(i);
res.push_back(ans + 1);
answer(res);
}
if(mn != -1){
l = k;
r = mn - 1;
while(l <= r){
int m = (l + r) / 2;
ll u = skim(m + 1);
if(arr[mn] + sum - arr[k - 2] + u < a) l = m + 1;
else if(arr[mn] + sum - arr[k - 2] + u > 2ll*a) r = m - 1;
else {
vector<int> res;
for(int i = 1; i < k - 1; i++) res.push_back(i);
res.push_back(m + 1);
res.push_back(mn + 1);
answer(res);
}
}
}
impossible();
}
//int main() {
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// #ifdef LOCAL
// freopen("input.txt", "r", stdin);
// #endif
// int tt;
// cin >> tt;
// tt = 1;
// while (tt--) {
// solve();
// #ifdef LOCAL
// cout << "__________________________________" << endl;
// #endif
// }
// #ifdef LOCAL
// cout << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << "sec" << '\n';
// #endif
// return 0;
//}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |