이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "books.h"
typedef long long ll;
typedef std::pair<ll , ll> llll;
typedef std::string str;
#define debug std::cout << "debug" << std::endl
#define pb push_back
ll kp[150000];
ll fun(ll x){
if(kp[x] == 0){
kp[x] = skim(x);
}
return kp[x];
}
void solve(int n , int m ,ll a , int s){
ll tot = 0;
for(ll i = 1;m>i;i++){
tot+=fun(i);
}
ll l = m , r = n+1;
while(r - l > 1){
ll md = (l+r)/2;
if(fun(md) + tot > 2ll *a){
r = md;
}
else{
l = md;
}
}
if(tot + fun(l) > 2ll *a){
impossible();
return;
}
if(tot + fun(l) >= a && 2ll *a >= tot + fun(l)){
std::vector<int> v;
for(ll i = 1;m>i;i++){
v.pb(i);
}
v.pb(l);
answer(v);
return;
}
for(ll i = m;i >= 0;i--){
ll ss = 0;
for(ll j =1;i>=j;j++){
ss+=fun(j);
}
for(ll j = 1;m - i>=j;j++){
ss+=fun(l - j + 1);
}
if(ss >= a && 2ll *a >= ss){
std::vector<int> v;
for(ll j =1;i>=j;j++){
v.pb(j);
}
for(ll j = 1;m - i>=j;j++){
v.pb(l - j + 1);
}
answer(v);
return;
}
tot = 0;
}
impossible();
}
/*int main(){
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
ll t = 1;std::cin >> t;
while(t--){
solve();
}
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... |