Submission #773023

#TimeUsernameProblemLanguageResultExecution timeMemory
773023ImeonA 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[N + 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];
              v.push_back(j);
            }
         if (l == 0 or d > 2LL * A)impossible(); 
         answer(v);
        impossible();
} 

Compilation message (stderr)

books.cpp:4:13: error: 'N' was not declared in this scope
    4 | long long x[N + 1];
      |             ^
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:8:9: error: 'x' was not declared in this scope
    8 |         x[i] = skim(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:23:9: error: 'x' was not declared in this scope
   23 |         x[i] = skim(i);
      |         ^
books.cpp:29:18: error: 'x' was not declared in this scope
   29 |             if ((x[md] + sm) > 2ll * A)r = md;
      |                  ^
books.cpp:33:15: error: 'x' was not declared in this scope
   33 |         sm += x[l];
      |               ^
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:15: error: 'v' was not declared in this scope
   45 |               v.push_back(j);
      |               ^
books.cpp:45:27: error: 'j' was not declared in this scope
   45 |               v.push_back(j);
      |                           ^
books.cpp:48:17: error: 'v' was not declared in this scope; did you mean 'v1'?
   48 |          answer(v);
      |                 ^
      |                 v1