제출 #773031

#제출 시각아이디문제언어결과실행 시간메모리
773031ImeonA Difficult(y) Choice (BOI21_books)C++17
컴파일 에러
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(); 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 = l; i < l + K;i++){ d += x[i]; v1.push_back(j); } if (l == 0 or d > 2LL * A)impossible(); answer(v1); impossible(); }

컴파일 시 표준 에러 (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:45:28: error: 'j' was not declared in this scope
   45 |               v1.push_back(j);
      |                            ^