Submission #635595

#TimeUsernameProblemLanguageResultExecution timeMemory
635595PanTkdA Difficult(y) Choice (BOI21_books)C++14
Compilation error
0 ms0 KiB
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iterator>
#include <limits>
#include <list>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include "books.h"

using namespace std;

typedef int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
#ifdef px
    #define p(x) cerr<<#x<<' '<<x<<endl;
#else
    #define p(x) {}
#endif
#define F first
#define S second
#define sz size
#define ls s,m,idx<<1
#define rs m+1,e,idx<<1|1
const ll MOD=ll(1e9)+7;
const ll MAXN=2*ll(1e6);


//
// --- 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) {
    // TODO implement this function
    vi X(N+1,ll());
    vi ans;
    queue<ll> q;
    for(ll i=1;i<=N;i++){
        X[i]=skim(i);    
    }
    for(ll i=1;i<=K;i++){
        sum+=X[i];
        q.insert(X[i]);
    }
    
    ll last=K+1;
    while(last<=N){
        bool ok=(sum>=A&&sum<=2*A);
        if(ok){
            while(!q.empty()){
                ans.push_back(q.top());
                q.pop();
            }
            answer(ans);
        }
        sum-=q.top();
        sum+=X[last];
        q.push(X[last]);
        last++;
    }
    bool ok=(sum>=A&&sum<=2*A);
    if(ok){
        while(!q.empty()){
            ans.push_back(q.top());
            q.pop();
        }
        answer(ans);
    }
    impossible();
}

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:59:9: error: 'sum' was not declared in this scope
   59 |         sum+=X[i];
      |         ^~~
books.cpp:60:11: error: 'class std::queue<int>' has no member named 'insert'
   60 |         q.insert(X[i]);
      |           ^~~~~~
books.cpp:65:18: error: 'sum' was not declared in this scope
   65 |         bool ok=(sum>=A&&sum<=2*A);
      |                  ^~~
books.cpp:68:33: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   68 |                 ans.push_back(q.top());
      |                                 ^~~
      |                                 pop
books.cpp:73:16: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   73 |         sum-=q.top();
      |                ^~~
      |                pop
books.cpp:78:14: error: 'sum' was not declared in this scope
   78 |     bool ok=(sum>=A&&sum<=2*A);
      |              ^~~
books.cpp:81:29: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   81 |             ans.push_back(q.top());
      |                             ^~~
      |                             pop