Submission #464037

#TimeUsernameProblemLanguageResultExecution timeMemory
464037MahdiBahramianA Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms296 KiB
#include<bits/stdc++.h> #include<books.h> #define pb push_back #define F first #define S second #define mk make_pair #define mt make_tuple using namespace std; typedef unsigned long long ll; const int Max = 5e5 + 10; ll ARR[Max]; bool ASK[Max]; int GET(int i) { if(ASK[i]) return ARR[i]; ASK[i] = 1; return ARR[i] = skim(i); } ll SUM(int l , int r) { ll ans = 0; for(int i = l ; i <= r ; i++) ans += GET(i); return ans; } void solve(int N , int K , long long A , int S) { if(SUM(1 , K) > 2 * A) return impossible(); if(SUM(1 , K) >= A) { vector<int> res; for(int i = 1 ; i <= K ; i++) res.pb(i); return answer(res); } int l = 0 , r = N + 1; while(r - l > 1) { int md = (l + r) >> 1; if(SUM(1 , K - 1) + GET(md) >= A) r = md; else l = md; } if(r <= N && SUM(1 , K - 1) + GET(r) <= 2 * A) { vector<int> res; for(int i = 1 ; i < K ; i++) res.pb(i); res.pb(r); return answer(res); } for(int ln = K - 1 ; ln >= 0 ; ln--) { if(SUM(1 , ln) + SUM(l - K + ln + 1 , l) >= A) { vector<int> res; for(int i = 1 ; i <= ln ; i++) res.pb(i); for(int i = l - K + ln + 1 ; i <= K ; i++) res.pb(i); return answer(res); } } //assert(0); return impossible(); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:26:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long unsigned int'} and 'long long int' [-Wsign-compare]
   26 |  if(SUM(1 , K) > 2 * A) return impossible();
      |     ~~~~~~~~~~~^~~~~~~
books.cpp:27:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long unsigned int'} and 'long long int' [-Wsign-compare]
   27 |  if(SUM(1 , K) >= A)
      |     ~~~~~~~~~~~^~~~
books.cpp:37:31: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long unsigned int'} and 'long long int' [-Wsign-compare]
   37 |   if(SUM(1 , K - 1) + GET(md) >= A) r = md;
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
books.cpp:41:39: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long unsigned int'} and 'long long int' [-Wsign-compare]
   41 |  if(r <= N && SUM(1 , K - 1) + GET(r) <= 2 * A)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
books.cpp:49:44: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long unsigned int'} and 'long long int' [-Wsign-compare]
   49 |   if(SUM(1 , ln) + SUM(l - K + ln + 1 , l) >= A)
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
#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...