Submission #773029

#TimeUsernameProblemLanguageResultExecution timeMemory
773029ImeonA Difficult(y) Choice (BOI21_books)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include"books.h" using namespace std; long long x[100000 + 1]; int h(int j){ int sm1 = 0; for (int i = j; i < j + k;i++){ x[i] = skim(i); sm1 += x[i]; if (i > K){sm1 -= x[i - K];} } /* if (sm >= A and sm <= 2LL * A){ return 1; }*/ return sm1; } void solve(int N, int K, long long A, int S) { // cin >> N >> K >> S >> A; long long sm = 0; K--; for (int i = 1; i <= K + 1;i++){ x[i] = skim(i); if (i <= K)sm += x[i]; } int l = K,r = N + 1; while (l + 1 < r){ int md = (l + r) / 2; if ((x[md] + sm) > 2ll * A)r = md; else l = md; } K++; sm += x[l]; if (l == K or sm > 2LL * A)impossible(); int l = 0,r = N + 1; while (l + 1 < r){ int md = (l + r) / 2; if (h(md) > 2ll * A)r = md; else l = md; } int d = 0; vector<int>v1; for (int i = md; i < md + K;i++){ d += x[i]; v1.push_back(j); } if (l == 0 or d > 2LL * A)impossible(); answer(v1); impossible(); }

Compilation message (stderr)

books.cpp: In function 'int h(int)':
books.cpp:7:29: error: 'k' was not declared in this scope
    7 |     for (int i = j; i < j + k;i++){
      |                             ^
books.cpp:10:17: error: 'K' was not declared in this scope
   10 |         if (i > K){sm1 -= x[i - K];}
      |                 ^
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:35:13: error: redeclaration of 'int l'
   35 |         int l = 0,r = N + 1;
      |             ^
books.cpp:26:13: note: 'int l' previously declared here
   26 |         int l = K,r = N + 1;
      |             ^
books.cpp:35:19: error: redeclaration of 'int r'
   35 |         int l = 0,r = N + 1;
      |                   ^
books.cpp:26:19: note: 'int r' previously declared here
   26 |         int l = K,r = N + 1;
      |                   ^
books.cpp:43:23: error: 'md' was not declared in this scope; did you mean 'd'?
   43 |          for (int i = md; i < md + K;i++){
      |                       ^~
      |                       d
books.cpp:45:28: error: 'j' was not declared in this scope
   45 |               v1.push_back(j);
      |                            ^