Submission #575027

#TimeUsernameProblemLanguageResultExecution timeMemory
575027RealSnakeA Difficult(y) Choice (BOI21_books)C++14
0 / 100
10 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; } for(int i = n; i >= n - k + 1; i--) { for(int j = 1; j < n - k + 1; j++) { if(b[j]) continue; if(sum - arr[i] + arr[j] > a) { sum -= arr[i]; sum += arr[j]; b[i] = 0, b[j] = 1; break; } } 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...