Submission #1204971

#TimeUsernameProblemLanguageResultExecution timeMemory
1204971Kel_MahmutHack (APIO25_hack)C++20
58 / 100
196 ms2064 KiB
#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 = 8000;
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){
            // cout << tl << ' ' << tr << ' ';
            int tm = (tl + tr + 1) / 2;
            vector<ll> r = {k * (x + 1)};
            for(int i = tm; i <= tr; i++){
                if(k * (x + 1) <= i) continue;
                r.pb(i);
            }
            ll ok = collisions(r);
            // cout << ok << endl;
            if(ok)
                tl = tm;
            else
                tr = 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;
    }
    // cout << tl << endl;
    return fin_get(tl);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...