제출 #1163661

#제출 시각아이디문제언어결과실행 시간메모리
1163661dpsaveslivesA Light Inconvenience (CEOI23_light)C++20
100 / 100
210 ms436 KiB
#include <bits/stdc++.h>
#include "light.h"
#define ll long long
using namespace std;

void prepare(){

}

vector<ll> cur = {1};
ll N = 1; //at the beginning
pair<ll,vector<ll>> solve(ll p){
    N += p;
    if(p < 0) p *= (-1);
    vector<ll> lit = {N};
    ll x = N;
    while(x > 1){
        x -= min(x-1,N-x+2);
        int ind = upper_bound(cur.begin(),cur.end(),x)-cur.begin()-1;
        if(x - cur[ind] >= p+1) x = cur[ind+1];
        lit.insert(lit.begin(),x);
    }
    swap(lit,cur);
    return {p,cur}; //light the rightmost p torches and leave the current ones
}
pair<ll,vector<ll>> join(ll p){
    return solve(p);
}
pair<ll,vector<ll>> leave(ll p){
    return solve(-p);
}
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...