제출 #406261

#제출 시각아이디문제언어결과실행 시간메모리
406261maomao90A Difficult(y) Choice (BOI21_books)C++17
80 / 100
4 ms328 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; #define mnto(x, y) x = min(x, (__typeof__(x)) y) #define mxto(x, y) x = max(x, (__typeof__(x)) y) #define REP(i, s, e) for (int i = s; i < e; i++) #define RREP(i, s, e) for (int i = s; i >= e; i--) typedef long long ll; typedef long double ld; #define MP make_pair #define FI first #define SE second typedef pair<int, int> ii; typedef pair<ll, ll> pll; #define MT make_tuple typedef tuple<int, int, int> iii; #define ALL(_a) _a.begin(), _a.end() #define pb emplace_back typedef vector<int> vi; typedef vector<ii> vii; #define INF 1000000005 #define LINF 1000000000000000005 #define MOD 1000000007 #define MAXN 100005 ll x[MAXN]; int todo[15]; void solve(int n, int k, ll a, int s) { if (s >= 170) { REP (i, 1, k + 1) { x[i] = skim(i); } ll sum = 0; REP (i, 1, k + 1) { todo[i] = i; sum += x[i]; } int prev = n; RREP (i, k, 1) { ll lo = i, hi = prev, mid; ll res = -1; while (lo <= hi) { mid = hi + lo >> 1; if (x[mid] == 0) x[mid] = skim(mid); if (sum + x[mid] - x[i] <= 2 * a) { lo = mid + 1; res = mid; } else { hi = mid - 1; } } sum = sum + x[res] - x[todo[i]]; todo[i] = res; prev = res - 1; } if (sum >= a && sum <= 2 * a) { vi ans; REP (i, 1, k + 1) { ans.pb(todo[i]); } answer(ans); return; } impossible(); return; } ll small = 0; REP (i, 1, k + 1) { x[i] = skim(i); small += x[i]; } ll big = 0; RREP (i, n, n - k + 1) { if (x[i] == 0) x[i] = skim(i); big += x[i]; } if (small > 2 * a) { impossible(); return; } else if (big < a) { impossible(); return; } ll lo = 0, hi = (ll) (n - k) * k, mid; while (lo <= hi) { mid = hi + lo >> 1; ll tmp = mid; RREP (i, k, 1) { ll sub = min(tmp, (ll) n - k); todo[i] = i + sub; tmp -= sub; } ll sum = 0; REP (i, 1, k + 1) { if (x[todo[i]] == 0) x[todo[i]] = skim(todo[i]); sum += x[todo[i]]; } if (sum < a) { lo = mid + 1; } else if (sum > 2 * a) { hi = mid - 1; } else { vi ans; REP (i, 1, k + 1) { ans.pb(todo[i]); } answer(ans); return; } } impossible(); }

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

books.cpp: In function 'void solve(int, int, ll, int)':
books.cpp:47:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   47 |    mid = hi + lo >> 1;
      |          ~~~^~~~
books.cpp:90:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   90 |   mid = hi + lo >> 1;
      |         ~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...