Submission #1334319

#TimeUsernameProblemLanguageResultExecution timeMemory
1334319ensonA Difficult(y) Choice (BOI21_books)C++20
0 / 100
1 ms1092 KiB
#include <bits/stdc++.h>
using namespace std;
#include "books.h"

void solve(int N, int K, long long A, int S){
    int l = 1, r = N;
    int m = (l+r)/2;
    vector<long long>F(N+1, -1);
    while (l < r){
        m = (l+r)/2;
        long long x = skim(m);
        F[m] = x;
        if (x >= A){
            r = m;
        } else {
            l = m+1;
        }
    }
    if (l < K-1 || l == 1) impossible();
    long long ans = 0;
    for(int i = 1; i < K; i++){
        F[i] = skim(i);
        ans += F[i];
    }
    ans += F[l];
    if (ans <= 2*A){
        vector<int>v;
        for(int i = 1; i < K; i++)v.push_back(i);
        v.push_back(l);
        answer(v);
    }
    if (l < K) impossible();
    for(int i = 0; i <= K; i++){
        vector<int>v;
        ans = 0;
        for(int j = 1; j < K-i+1; j++){
            if (F[j] == -1)F[j] = skim(j);
            ans += F[j];
            v.push_back(j);
        }
        for(int j = l-1; j >= l-i; j--){
            if (F[j] == -1)F[j] = skim(j);
            ans += F[j];
            v.push_back(j);
        }
        if (ans >= A && ans <= 2*A) answer(v);
    }
    impossible();
}
#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...