Submission #1368557

#TimeUsernameProblemLanguageResultExecution timeMemory
1368557kahoulPetrol stations (CEOI24_stations)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

#include "books.h"

#define int long long
using namespace std;
//
// --- Sample implementation for the task books ---
//
// To compile this program with the sample grader, place:
//     books.h books.cpp grader.cpp
// in a single folder and run:
//     g++ books.cpp grader.cpp
// in this folder.
//

int N;
map<int, int> vals;

int get (int x) {
    if (x == N) return 1e18;
    return vals[x] = (vals.count(x) ? vals[x] : skim(x + 1));
}

vector<signed> ans;

void solve(signed n, signed k, long long A, signed s) {
    N = n;

    int min_sum = 0; for (int i = 0; i < k; i++) min_sum += get(i);
    if (min_sum > 2 * A) { impossible(); return; }
    if (min_sum >= A) {
        for (int i = 0; i < k; i++) ans.push_back(i + 1);
        answer(ans);
        return;
    }

    int l = 0, r = n;
    while (l < r) {
        int m = (l + r) / 2;
        if (get(m) >= A) r = m;
        else l = m + 1;
    }

    if (min_sum - get(k - 1) + get(l) <= 2 * A) {
        for (int i = 0; i < k - 1; i++) ans.push_back(i + 1);
        ans.push_back(l + 1);
        answer(ans);
        return;
    }

    int a = k - 1, b = l - 1;
    int sum = min_sum;
    while (a >= 0 && b >= 0) {
        sum -= get(a);
        sum += get(b);
        if (sum >= A) break;
        a--; b--;
    }

    if (sum < A) {
        impossible(); return;
    }

    for (int i = 0; i < a; i++) ans.push_back(i + 1);
    for (int i = b; i < l; i++) ans.push_back(i + 1);
    answer(ans);    
}

Compilation message (stderr)

Main.cpp:3:10: fatal error: books.h: No such file or directory
    3 | #include "books.h"
      |          ^~~~~~~~~
compilation terminated.