Submission #1333742

#TimeUsernameProblemLanguageResultExecution timeMemory
1333742zhehanA Difficult(y) Choice (BOI21_books)C++20
Compilation error
0 ms0 KiB
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);
}

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:3:3: error: 'vector' was not declared in this scope
    3 |   vector<int> books(N, 0);
      |   ^~~~~~
books.cpp:3:10: error: expected primary-expression before 'int'
    3 |   vector<int> books(N, 0);
      |          ^~~
books.cpp:5:5: error: 'books' was not declared in this scope
    5 |     books[i] = skim(i);
      |     ^~~~~
books.cpp:5:16: error: 'skim' was not declared in this scope
    5 |     books[i] = skim(i);
      |                ^~~~
books.cpp:8:19: error: 'books' was not declared in this scope
    8 |       lower_bound(books.begin(), books.end(), (A + K - 1) / K) - books.begin();
      |                   ^~~~~
books.cpp:8:7: error: 'lower_bound' was not declared in this scope
    8 |       lower_bound(books.begin(), books.end(), (A + K - 1) / K) - books.begin();
      |       ^~~~~~~~~~~
books.cpp:10:10: error: expected primary-expression before 'int'
   10 |   vector<int> ans(K, 0);
      |          ^~~
books.cpp:13:5: error: 'ans' was not declared in this scope
   13 |     ans[i] = i + ind;
      |     ^~~
books.cpp:19:5: error: 'ans' was not declared in this scope
   19 |     ans[i] = ind + i - K;
      |     ^~~
books.cpp:22:9: error: 'impossible' was not declared in this scope
   22 |         impossible();
      |         ^~~~~~~~~~
books.cpp:25:10: error: 'ans' was not declared in this scope
   25 |   answer(ans);
      |          ^~~
books.cpp:25:3: error: 'answer' was not declared in this scope
   25 |   answer(ans);
      |   ^~~~~~