제출 #575511

#제출 시각아이디문제언어결과실행 시간메모리
575511birthdaycakeA Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms336 KiB
#include <bits/stdc++.h>
 
#include "books.h"
 
using namespace std;
 
long long b[200001], vs[200001];
void solve(int n, int k, long long a, int s) {
    long long tot = 0;
    for(int i = 1; i <= k; i++){
        b[i] = skim(i);
        tot += b[i];
    }
    int pst = n;
    vector<int>fin;
    for(int i = k; i >= 1; i--){
        int l = i + 1, r = pst, prev = i;
        while(l <= r){
            int mid = (l + r) / 2;
            if(!b[mid]) b[mid] = skim(mid);
            if(tot - b[prev] + b[mid] <= 2 * a){
                prev = mid;
                l = mid + 1;
            }else{
                r = mid - 1;
            }
        }
        tot -= b[i];
        tot += b[prev];
        vs[prev] = 1;
        pst = prev - 1;
    }
    tot = 0;
    for(int i = 1; i <= n; i++){
        if(vs[i]){
            fin.push_back(i);
            tot += b[i];
        }
    }
    if(tot >= a && tot <= 2 * a) answer(fin);
    
    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...