Submission #721167

#TimeUsernameProblemLanguageResultExecution timeMemory
721167FatihSolakA Difficult(y) Choice (BOI21_books)C++17
30 / 100
2 ms332 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; int cnt = 0; long long get(int pos){ assert(cnt++ <= 40); return skim(pos); } void solve(int n, int k, long long a, int s){ int l = 1,r = n+1; while(l < r){ int m = (l+r)/2; if(get(m) < a){ l = m + 1; } else r = m; } vector<pair<int,long long>> x; vector<pair<int,long long>> y; for(int i = 1;i<=k;i++){ x.push_back({i,get(i)}); } if(l < k){ impossible(); } if(l != n+1){ long long sum = get(l); for(int i = 0;i<k-1;i++){ sum += x[i].second; } if(a <= sum && sum <= 2*a){ vector<int> ret; for(int i = 1;i<=k-1;i++){ ret.push_back(i); } ret.push_back(l); assert(ret.size() == k); answer(ret); } } if(l == k){ impossible(); } for(int i = k;i>=1;i--){ y.push_back({l-i,get(l-i)}); } long long sum = 0; for(auto u:x){ sum += u.second; } if(a <= sum && sum <= 2*a){ vector<int> ret; for(int i = 1;i<=k;i++){ ret.push_back(i); } assert(ret.size() == k); answer(ret); } if(sum > 2*a){ impossible(); } for(int i = 1;i<=k;i++){ sum -= x[k-i].second; sum += y[k-i].second; if(a <= sum && sum <= 2*a){ vector<int> ret; for(int j = 1;j<=k-i;j++){ ret.push_back(i); } for(int j = k-1;j>=k-i;j--){ ret.push_back(y[j].first); } assert(ret.size() == k); sort(ret.begin(),ret.end()); answer(ret); } assert(sum < a); } impossible(); }

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from books.cpp:1:
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:39:32: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |             assert(ret.size()  == k);
      |                    ~~~~~~~~~~~~^~~~
books.cpp:58:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |         assert(ret.size()  == k);
      |                ~~~~~~~~~~~~^~~~
books.cpp:75:32: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   75 |             assert(ret.size()  == k);
      |                    ~~~~~~~~~~~~^~~~
#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...