제출 #933710

#제출 시각아이디문제언어결과실행 시간메모리
933710AtabayRajabliA Difficult(y) Choice (BOI21_books)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; const int sz = 1e5 + 5; long long q[sz]; long long get(long long x) { if(q[x])return q[x]; return q[x] = skim(x); } void solve(int n, int k, long long a, int s) { long long sum = 0; vector<int> v; for(int i = 1; i <= k; i++) { sum += get(i); v.push_back(i); } if(sum > 2 * a)impossible(); if(a <= sum)answer(v); long long mx = 2 * a - (sum - get(k)); int l = k + 1, r = n, j = n + 1; while(l <= r) { int m = (l + r) >> 1; if(get(m) <= mx)l = m + 1, j = m; else r = m - 1; } if(j == n + 1)impossible(); if(sum - get(k) + get(j) >= a) { v.pop_back(); v.push_back(j); answer(v); } int r = j; set<int> cur; for(int i = 1; i <= k; i++)cur.insert(i); for(int i = 1; r > k; i++) { sum -= get(i); cur.erase(i); sum += get(r); cur.insert(r); r--; if(a <= sum) { vector<int> ans; for(int i : cur)ans.push_back(i); answer(ans); } } impossible(); }

컴파일 시 표준 에러 (stderr) 메시지

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:46:9: error: redeclaration of 'int r'
   46 |     int r = j;
      |         ^
books.cpp:29:20: note: 'int r' previously declared here
   29 |     int l = k + 1, r = n, j = n + 1;
      |                    ^