Submission #1135375

#TimeUsernameProblemLanguageResultExecution timeMemory
1135375eradaxA Difficult(y) Choice (BOI21_books)C++20
Compilation error
0 ms0 KiB
#include "books.h"
#include <bits/stdc++.h>

/*
Either the answer is K consecutive numbers or

*/
void solve(int N, int K, ll A, int S) {
  vl vals(N);

  rep(i, N) {
    vals[i] = skim(i + 1);
    S--;
  }

  ll sum = 0;
  int l = 0, r = K;
  rep(i, K) { sum += vals[i]; }

  while (r < N) {
    if (A <= sum && sum <= 2 * A) {
      break;
    }

    if (sum < A) {
      sum += vals[r++];
      sum -= vals[l++];
    } else {
      break;
    }
  }

  if (A <= sum && sum <= 2 * A) {
    vi ans(K);
    rep(i, K) { ans[i] = l + i + 1; }

    answer(ans);
    return;
  } else {
    int i = 0;
    while (i < N && vals[i] < A)
      i++;
    if (K <= i && i < N) {
      ll sum = 0;
      rep(j, K - 1) { sum += vals[j]; }
      sum += vals[i];

      if (A <= sum && sum <= 2 * A) {
        vi ans(K);
        rep(j, K - 1) { ans[j] = j + 1; }
        ans[K - 1] = i + 1;

        answer(ans);
        return;
      }
    }

    impossible();
  }
}

Compilation message (stderr)

books.cpp:8:26: error: 'll' has not been declared
    8 | void solve(int N, int K, ll A, int S) {
      |                          ^~
books.cpp: In function 'void solve(int, int, int, int)':
books.cpp:9:3: error: 'vl' was not declared in this scope
    9 |   vl vals(N);
      |   ^~
books.cpp:11:7: error: 'i' was not declared in this scope
   11 |   rep(i, N) {
      |       ^
books.cpp:11:3: error: 'rep' was not declared in this scope
   11 |   rep(i, N) {
      |   ^~~
books.cpp:16:3: error: 'll' was not declared in this scope
   16 |   ll sum = 0;
      |   ^~
books.cpp:21:14: error: 'sum' was not declared in this scope
   21 |     if (A <= sum && sum <= 2 * A) {
      |              ^~~
books.cpp:25:9: error: 'sum' was not declared in this scope
   25 |     if (sum < A) {
      |         ^~~
books.cpp:26:14: error: 'vals' was not declared in this scope
   26 |       sum += vals[r++];
      |              ^~~~
books.cpp:33:12: error: 'sum' was not declared in this scope
   33 |   if (A <= sum && sum <= 2 * A) {
      |            ^~~
books.cpp:34:5: error: 'vi' was not declared in this scope
   34 |     vi ans(K);
      |     ^~
books.cpp:37:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |     answer(ans);
      |            ^~~
      |            abs
books.cpp:41:21: error: 'vals' was not declared in this scope
   41 |     while (i < N && vals[i] < A)
      |                     ^~~~
books.cpp:44:9: error: expected ';' before 'sum'
   44 |       ll sum = 0;
      |         ^~~~
      |         ;
books.cpp:45:11: error: 'j' was not declared in this scope
   45 |       rep(j, K - 1) { sum += vals[j]; }
      |           ^
books.cpp:46:14: error: 'vals' was not declared in this scope
   46 |       sum += vals[i];
      |              ^~~~
books.cpp:49:9: error: 'vi' was not declared in this scope; did you mean 'i'?
   49 |         vi ans(K);
      |         ^~
      |         i
books.cpp:51:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   51 |         ans[K - 1] = i + 1;
      |         ^~~
      |         abs