Submission #729158

#TimeUsernameProblemLanguageResultExecution timeMemory
729158Jean7A Difficult(y) Choice (BOI21_books)C++14
20 / 100
222 ms592 KiB
#include <bits/stdc++.h> #include "books.h" #define mid ((l+r)>>1) using namespace std ; const long long N = 1e5+5 ; long long a[N] ; void solve(int n, int k, long long A, int s) { long long sum = 0 ; vector <int> v ; for ( long long i = 1 ; i <= k ; i++ ) { a[i] = skim(i) ; sum += a[i] ; v.push_back(i) ; } if ( sum > 2ll * A ) { impossible () ; } long long id = k , xx = n+1 ; while ( sum < A && id > 0 ) { long long l = id , r = xx ; while ( l < r ) { if ( !a[l] ) { a[l] = skim(l) ; } if ( sum + a[l] - a[id] > 2ll * A ) { break ; } l++ ; } // while ( r - l > 1 ) { // if ( !a[mid] ) { // a[mid] = skim(mid) ; // } // if ( sum + a[mid] - a[id] <= 2 * A ) { // l = mid ; // } // else { // r = mid ; // } // } sum -= a[id] ; sum += a[l-1] ; v[id-1] = l-1 ; xx = l-1 ; id-- ; } if ( sum < A ) { impossible () ; } answer(v) ; }
#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...