#include "hack.h"
#include <vector>
#include <bits/stdc++.h>
#define pb push_back
#define endl ("\n")
#define all(aa) aa.begin(), aa.end()
typedef long long ll;
using namespace std;
const int N = 1e9;
const int k = 32000;
const int b = N / k;
int hack(){
vector<ll> s(k);
for(int i = 0; i < k; i++) s[i] = i + 1;
function<ll(int, int)> get = [&](int tl, int tr){
vector<ll> r;
for(int i = tl; i <= tr; i++){
if((i + 1) * k <= k) continue;
r.pb((i + 1) * k);
}
for(int i : s) r.pb(i);
return collisions(r);
};
function<int(int)> fin_get = [&](int x){
// [x * k, x * (k + 1))
int tl = 1, tr = k;
while(tr > tl){
int tm = (tl + tr) / 2;
vector<ll> r = {k * (x + 1)};
for(int i = tl; i <= tm; i++) r.pb(i);
ll ok = collisions(r);
if(ok)
tr = tm;
else
tl = tm + 1;
}
return (x + 1) * k - tl;
};
int tl = 0, tr = b;
while(tl < tr){
int tm = (tl + tr) / 2;
if(get(tl, tm))
tr = tm;
else
tl = tm + 1;
}
return fin_get(tl);
}
# | 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... |