제출 #1333623

#제출 시각아이디문제언어결과실행 시간메모리
1333623WongYiKaiA Difficult(y) Choice (BOI21_books)C++17
20 / 100
0 ms412 KiB
#include <bits/stdc++.h>

#include "books.h"
typedef long long ll;

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

void solve(int n, int k, long long a, int s) {
    ll first = 0;
    ll val[k+5];
    for (int i=0;i<k-1;i++){
        val[i+1] = skim(i+1);
        first += val[i+1];
    }
    ll l = k, r = n+1;
    while (l<r){
        ll m = (l+r)>>1;
        if (first + skim(m) > 2*a) r=m;
        else l = m+1;
    }
    ll idx = l-1;
    if (first + skim(idx) >= a){
        vector<int> ans;
        for (int i=1;i<k;i++) ans.push_back(i);
        ans.push_back(idx);
        answer(ans);
    }
    ll total = 0;
    ll cnt = k;
    val[k] = 0;
    for (int j=idx;j>idx-k;j--){
        total += skim(j);
        first -= val[cnt];
        cnt--;
        if (total >= a){
            vector<int> ans;
            for (int i=1;i<=cnt;i++) ans.push_back(i);
            for (int i=j;i<=idx;i++) ans.push_back(i);
            answer(ans);
        }
    }
    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...