Submission #530155

#TimeUsernameProblemLanguageResultExecution timeMemory
530155benedict0724A Difficult(y) Choice (BOI21_books)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; void solve(int N, int K, long long A, int S) { int l = 1, r = N+1; while(l < r) { int mid = (l + r)/2; if(skim(mid) > A) r = mid; else l = mid + 1; } if(l < K) { impossible(); return; } if(l == K) { long long ans = 0; for(int i=1;i<=K;i++) ans += skim(i); vector<int> v; for(int i=1;i<=K;i++) v.push_back(i); if(A <= ans && ans <= 2*A) answer(v); else impossible(); return; } long long a[11], b[11]; for(int i=1;i<=K;i++) { a[i] = skim(i); b[i] = skim(l-K+i-1); } if(l <= N) { long long ans = 0; for(int i=1;i<K;i++) ans += a[i]; ans += skim(l); vector<int> v; if(A <= ans && ans <= 2*A) { for(int i=1;i<K;i++) v.push_back(i); v.push_back(l); answer(v); return; } } ans = 0; for(int i=1;i<=K;i++) ans += a[i]; if(ans > 2*A) { impossible(); return; } for(int i=1;i<=K;i++) v.push_back(i); for(int i=K;i>=0;i--) { if(A <= ans && ans <= 2*A) { answer(v); return; } if(i == 0) break; v[i-1] = l-K+i-1; ans += b[i] - a[i]; } impossible(); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:53:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   53 |     ans = 0;
      |     ^~~
      |     abs
books.cpp:60:27: error: 'v' was not declared in this scope
   60 |     for(int i=1;i<=K;i++) v.push_back(i);
      |                           ^
books.cpp:65:20: error: 'v' was not declared in this scope
   65 |             answer(v);
      |                    ^
books.cpp:69:9: error: 'v' was not declared in this scope
   69 |         v[i-1] = l-K+i-1;
      |         ^