제출 #1032271

#제출 시각아이디문제언어결과실행 시간메모리
1032271Maite_MoraleA Difficult(y) Choice (BOI21_books)C++14
0 / 100
1 ms600 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll ; #define vll vector<ll> #define vi vector<int> long long skim(int); void answer(std::vector<int>); void impossible(); void solve(int n, int k, long long A, int S) { vi v(n+5,0),knowed,r={};ll s=0; for(int i=1;i<=k;i++){ r.push_back(i); v[i]=skim(i);s+=v[i]; } if(s>2*A){ impossible(); return; } ll last=n+1; for(int i=k;i>0;i--){ s-=v[i]; ll p=i,f=last; while(abs(p-f)!=1){ ll md=(p+f)/2; if(v[md]==0)v[md]=skim(md); if(s+v[md]<A)p=md; else if(s+v[md]>2*A)f=md; else{ r[i-1]=md; answer(r); return; } }//for(auto x : r)cout<<x<<" ";cout<<"\n"; r[i-1]=p; s+=v[p]; last=p; } 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...