제출 #657355

#제출 시각아이디문제언어결과실행 시간메모리
657355LoboA Difficult(y) Choice (BOI21_books)C++17
0 / 100
2 ms1976 KiB
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
//
// --- 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.
//

int n;
void solve(int N, int k, long long A, int S) {
    n = N;
    // TODO implement this function

    vector<int> b(n+1,0), pf(n+1,0);
    for(int i = 1; i <= n; i++) {
        b[i] = skim(i);
        pf[i] = pf[i-1]+b[i];
        assert(pf[i] > 1e17);
    }

    for(int i = 1; i <= n; i++) {
        // r-l+1 = k -> l = r-k+1
        int r = i;
        int l = r-k+1;
        if(l < 1) continue;
        if(pf[r]-pf[l-1] >= A && pf[r]-pf[l-1] <= 2*A) {
            vector<int> ans;
            for(int j = l; j <= r; j++) {
                ans.pb(j);
            }
            answer(ans);
            return;
        }
    }

    for(int i = k; i <= n; i++) {
        // (1,k-1) and i
        if(pf[k-1]+b[i] >= A && pf[k-1]+b[i] <= 2*A) {
            vector<int> ans;
            for(int j = 1; j <= k-1; j++) {
                ans.pb(j);
            }
            ans.pb(i);
            answer(ans);
            return;
        }
    }

    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...