제출 #1333738

#제출 시각아이디문제언어결과실행 시간메모리
1333738zhehanA Difficult(y) Choice (BOI21_books)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>

#include "books.h"

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) {
  // TODO implement this function
  vector<int> books(N, 0);
  for (int i = 1; i <= n; ++i) {
    books[i] = skim(i);
  }
  int ind =
      lower_bound(books.begin(), books.end(), (A + K - 1) / K) - books.begin();
  int sum = 0;
  vector<int> ans(K, 0);
  for (int i = 0; i < K; ++i) {
    sum += books[i + ind];
    ans[i] = i + ind;
  }
  int i = K - 1;
  while (sum > 2 * A) {
    sum -= books[i + ind];
    sum += books[ind + i - K];
    ans[i] = ind + i - K;
    --i;
    if(i<0){
        impossible()
    }
  }
  answer(ans);
}

컴파일 시 표준 에러 (stderr) 메시지

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:19:24: error: 'n' was not declared in this scope
   19 |   for (int i = 1; i <= n; ++i) {
      |                        ^
books.cpp:37:21: error: expected ';' before '}' token
   37 |         impossible()
      |                     ^
      |                     ;
   38 |     }
      |     ~