제출 #723317

#제출 시각아이디문제언어결과실행 시간메모리
723317MardukA Difficult(y) Choice (BOI21_books)C++14
0 / 100
1 ms292 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; void solve(int N, int K, long long A, int S){ vector<int> sol; int lo = 0, hi = N+1; while(hi-lo>1){ int mid = (lo+hi)/2; if(skim(mid) >= A) hi = mid; else lo = mid; } int x = hi; int vx = skim(x); long long ans = 0; vector<int> f,l; f.clear(); l.clear(); for(int i = 1;i<K;i++){ long long q = skim(i); ans+=q; f.push_back(q); q = skim(x-i); l.push_back(q); } if(ans+vx >= A && ans+vx <= 2*A){ for(int i = 1;i<K;i++) sol.push_back(i); sol.push_back(x); answer(sol); return; } if(K>=x) impossible(); f.push_back(skim(K)); ans+=f[K-1]; if(ans >= A && ans <= 2*A){ for(int i = 1;i<=K;i++) sol.push_back(i); answer(sol); return; } for(int i = 0;i<K;i++){ if(f[i] == l[i]) impossible(); ans-=f[i]; ans+=l[i]; if(ans >= A && ans <= 2*A){ for(int j = 1+i+1;j<=K;j++) sol.push_back(j); for(int j = x-1;j>=x-1-i;j--) sol.push_back(j); answer(sol); 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...