제출 #1367524

#제출 시각아이디문제언어결과실행 시간메모리
1367524sukritp5Hack (APIO25_hack)C++20
78.10 / 100
107 ms1280 KiB
#include "hack.h"
#include <vector>
#include <math.h>
// #include <iostream>
using namespace std;

int hack(){
    vector<long long> x;
    // x={1,48,49,50};
    // long long a=collisions(x);
    // std::cout<<a<<' ';
    int l=2,r=1000000000;
    while(l<r){
        x.clear();
        int mid=(l+r)/2;
        int k=sqrt(mid-l+1);
        if(k==0){
            x.emplace_back(1);
            x.emplace_back(mid+1);
            long long a=collisions(x);
            if(a)return mid;
            return r;
        }
        for(int i=1;i<=k;i++)x.emplace_back(i);
        int now=min(l+k,mid);
        while(now<=mid){
            x.emplace_back(now);
            now+=k;
            // cout<<now<<' ';
        }
        x.emplace_back(mid+1);
        long long a=collisions(x);
        if(a)r=mid;
        else l=mid+1;
        // std::cout<<'\n';
        // std::cout<<l<<' '<<r<<'\n';
        // for(auto v:x)std::cout<<v<<' ';
        // std::cout<<'\n';
    }

    return r;
    // return -1;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…