제출 #575005

#제출 시각아이디문제언어결과실행 시간메모리
575005RealSnakeA Difficult(y) Choice (BOI21_books)C++14
0 / 100
12 ms976 KiB
#include "bits/stdc++.h" using namespace std; #include "books.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #define ll long long #define mod 1000000007 void solve(int n, int k, ll a, int S) { ll arr[n + 1]; for(int i = 1; i <= n; i++) arr[i] = skim(i); ll sum = 0; for(int i = 1; i <= k; i++) sum += arr[i]; vector<int> ans; for(int i = 1; i <= k; i++) ans.push_back(i); if(sum >= a && sum <= 2 * a) { answer(ans); return; } if(sum < a) { int L = k + 1, R = n; for(int i = k; i >= 1; i--) { int l = L, r = R; while(l <= r) { int mid = (l + r) / 2; sum -= arr[ans[i - 1]]; sum += arr[mid]; ans[i - 1] = mid; if(sum >= a && sum <= 2 * a) { answer(ans); return; } if(sum < a) l = mid + 1; else r = mid - 1; } L = i, R = ans[i - 1] - 1; } } impossible(); }
#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...