Submission #646689

#TimeUsernameProblemLanguageResultExecution timeMemory
646689beaconmcA Difficult(y) Choice (BOI21_books)C++14
100 / 100
1 ms352 KiB
#include <bits/stdc++.h> #include "books.h" typedef long long ll; using namespace std; #define FOR(i, x, y) for(ll i=x; i<y; i++) #define FORNEG(i, x, y) for(ll i=x; i>y; i--) #define fast() ios_base::sync_with_stdio(false);cin.tie(NULL) // // --- Sample implementation for the task books --- // // To compile this program with the sample grader, place: // books.h books_sample.cpp sample_grader.cpp // in a single folder and run: // g++ books_sample.cpp sample_grader.cpp // in this folder. // ll n,k,a,s; map<ll,ll> cache; ll skimm(ll x){ if (cache[x] != 0) return cache[x]; else{ cache[x] = skim(x); return cache[x]; } } bool query(ll x){ ll sus = skimm(x); if (sus*k + k*(k-1)/2 > 2*a){ return true; } return false; } void solve(int N, int K, long long A, int S) { n = N; k = K; a = A; s = S; ll lo = 1; ll hi = n; while (lo<hi){ ll mid = lo + (hi - lo) / 2; if (query(mid)){ hi = mid; }else{ lo = mid+1; } } vector<ll> sus; ll mini = max(ll(1), lo-k); FOR(i,lo-k, lo+k-1){ if (0<i && i<=n){ sus.push_back(skimm(i)); } } FOR(i,0,sus.size()-k+1){ ll suss = 0; FOR(j,i,i+k){ suss += sus[j]; } if (A <= suss && suss <= 2*A){ vector<int> ans; FOR(p,i,i+k){ ans.push_back(p+mini); } answer(ans); return; } } ll realsus = 0; FOR(i,1,k){ realsus += skimm(i); } FOR(i,0,sus.size()){ if (a<= realsus+sus[i] && realsus+sus[i] <= 2*a){ vector<int> ans; FOR(j,1,k){ ans.push_back(j); } ans.push_back(i+mini); answer(ans); return; } } impossible(); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:11:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'long long unsigned int' [-Wsign-compare]
   11 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
   87 |     FOR(i,0,sus.size()-k+1){
      |         ~~~~~~~~~~~~~~~~~~         
books.cpp:87:5: note: in expansion of macro 'FOR'
   87 |     FOR(i,0,sus.size()-k+1){
      |     ^~~
books.cpp:11:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
  109 |     FOR(i,0,sus.size()){
      |         ~~~~~~~~~~~~~~             
books.cpp:109:5: note: in expansion of macro 'FOR'
  109 |     FOR(i,0,sus.size()){
      |     ^~~
#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...