Submission #401980

# Submission time Handle Problem Language Result Execution time Memory
401980 2021-05-11T05:46:38 Z blue A Difficult(y) Choice (BOI21_books) C++17
0 / 100
1 ms 968 KB
#include "books.h"
#include <vector>
#include <algorithm>
using namespace std;

long long n;
long long k;
long long a;

vector<long long> diff(100001);

vector<int> res;
long long curr_sum = 0;

int L, R;

void res_search(long long l, long long books)
{
    // cerr << "rs " << l << ' ' << books << '\n';


    res.push_back(l);
    curr_sum += diff[l];

    if(books-1 == 0)
    {
        if(a <= curr_sum && curr_sum <= 2*a)
            answer(res);

        return;
    }

    for(long long r = l+1; r <= R; r++)
        res_search(r, books-1);

}



void binary_search(long long l, long long r)
{
    // cerr << "bs " << l << ' ' << r << '\n';
    if(l == r)
    {
        L = max(1LL, l-k+1);
        R = min(n, r+k);
        for(long long i = L; i <= R; i++)
            diff[i] = skim(i);

        res_search(L, k);
        impossible();
    }
    else
    {
        long long m = (l+r)/2 + 1;
        if(k*skim(m) <= a*2)
            return binary_search(m, r);
        else
            return binary_search(l, m-1);
    }
}


       //books, choice size, limit,  skim limit
void solve(int N, int K, long long A, int S)
{
    skim(N+1);
    n = N;
    k = K;
    a = A;

    binary_search(1LL, n);
}

# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 968 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 968 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 968 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 968 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 968 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 968 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 968 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -