This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//khodaya khodet komak kon
# include <bits/stdc++.h>
# include "books.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
typedef pair <pii, pii> ppp;
typedef pair <ll, ll> pll;
# define A first
# define B second
# define endl '\n'
# define sep ' '
# define all(x) x.begin(), x.end()
# define kill(x) return cout << x << endl, 0
# define SZ(x) int(x.size())
# define lc id << 1
# define rc id << 1 | 1
# define fast_io ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}
const int xn = 1e5 + 10;
const int xm = - 20 + 10;
const int sq = 320;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const ld eps = 1e-15;
const int mod = 1e9 + 7;//998244353;
const int base = 257;
int m;
pll a[xn];
set <pll> st;
void solve(int n, int k, ll A, int s){
int lb = 0, rb = n + 1;
while (1 < rb - lb){
int md = (lb + rb) / 2;
if (skim(md) < A)
lb = md;
else
rb = md;
}
rb = min(rb, n);
if (rb < k){
impossible();
return;
}
st.clear();
for (int i = 1; i <= k; ++ i)
st.insert({skim(i), i});
for (int i = rb - k + 1; i <= rb; ++ i)
st.insert({skim(i), i});
m = 0;
for (pll x : st)
a[m ++] = x;
for (int mask = 0; mask < (1 << m); ++ mask){
ll ted = 0, sum = 0;
for (int i = 0; i < m; ++ i)
if ((mask & (1 << i)))
++ ted, sum += a[i].A, sum = min(sum, INF);
if (ted != k || sum < A || A + A < sum)
continue;
vector <int> ans;
for (int i = 0; i < m; ++ i)
if ((mask & (1 << i)))
ans.push_back(a[i].B);
answer(ans);
return;
}
impossible();
}
/*
int main(){
fast_io;
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... |