제출 #575020

#제출 시각아이디문제언어결과실행 시간메모리
575020RealSnakeA Difficult(y) Choice (BOI21_books)C++14
0 / 100
3 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; bool b[n + 1] = {}; for(int i = n; i >= n - k + 1; i--) { sum += arr[i]; b[i] = 1; } if(sum >= a && sum <= 2 * a) { vector<int> ans; for(int i = n - k + 1; i <= n; i++) ans.push_back(i); answer(ans); return; } if(sum < a) { impossible(); return; } set<pair<ll, int>> s; for(int i = 1; i < n - k + 1; i++) s.insert({arr[i], i}); int j = n - k; for(int i = n; i >= n - k + 1 && j >= 1; i--) { auto it = s.lower_bound({(2 * a) - sum, 0}); if(it != s.end()) { pair<ll, int> p = *it; sum -= arr[i]; sum += p.first; b[i] = 0, b[p.second] = 1; } if(sum >= a && sum <= 2 * a) { vector<int> ans; for(int i = 1; i <= n; i++) { if(b[i]) ans.push_back(i); } answer(ans); return; } } 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...