이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include "books.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pdd pair<ld, ld>
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update> ordset;
#pragma GCC optimize("-O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-Os")
ll INF = 1e18;
ll mod = 1e9 + 7;
mt19937 gen(time(0));
void solve(int n, int k, ll a, int s){
int l = 1, r = n, ans = n;
while(l <= r){
int m = (l + r) / 2;
ll u = skim(m);
if(u >= a){
ans = m;
r = m - 1;
} else l = m + 1;
}
vector<pll> b;
for(int i = 1; i <= min(k, ans); i++) b.push_back({skim(i), (ll)i});
for(int i = max(min(k, ans) + 1, ans - k); i <= ans; i++) b.push_back({skim(i), (ll)i});
int n1 = (int)b.size();
for(int mask = 0; mask < (1 << n1); mask++){
ll sum = 0;
for(int i = 0; i < n1; i++) if(mask & (1 << i)) sum += b[i].ff;
if(sum >= a && sum <= 2ll*a && __builtin_popcount(mask) == k){
vector<int> res;
for(int i = 0; i < n1; i++) if(mask & (1 << i)) res.push_back(b[i].ss);
answer(res);
}
}
impossible();
}
//int main() {
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// #ifdef LOCAL
// freopen("input.txt", "r", stdin);
// #endif
// int tt;
// cin >> tt;
// tt = 1;
// while (tt--) {
// solve();
// #ifdef LOCAL
// cout << "__________________________________" << endl;
// #endif
// }
// #ifdef LOCAL
// cout << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << "sec" << '\n';
// #endif
// return 0;
//}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |