Submission #1174188

#TimeUsernameProblemLanguageResultExecution timeMemory
1174188LucaIlieA Light Inconvenience (CEOI23_light)C++20
100 / 100
201 ms436 KiB
#include "light.h"
#include <bits/stdc++.h>

using namespace std;

long long n;
vector<long long> light;

void prepare(){
	n = 1;
    light.push_back( 1 );
}

void getLight( long long p ) {
    n += p;   

    while ( light.back() > n )
        light.pop_back();
    light.push_back( n );

    vector<long long> newLight;
    newLight.push_back( n );
    long long x = 1;
    while ( x < n ) {
        //vreau ceva intre n-2x si n-x
        long long y = n - x;
        if ( (*lower_bound( light.begin(), light.end(), n - 2 * x - abs( p ))) <= n - 2 * x )
            y = n - 2 * x;
        else
            y = (*lower_bound( light.begin(), light.end(), n - 2 * x ));
        newLight.push_back( y );
        x = n - y + 1;
        //printf( "%d %d %d\n", n, x, y );
    }
    reverse( newLight.begin(), newLight.end() );
    light = newLight;
}

pair<long long, vector<long long>> join( long long p ) {
    getLight( p );
    return { p, light };
}

pair<long long, vector<long long>> leave( long long p ) {
    getLight( -p );
    return { p, light };
}

#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...