Submission #657613

#TimeUsernameProblemLanguageResultExecution timeMemory
657613TimDeeA Difficult(y) Choice (BOI21_books)C++17
0 / 100
3 ms228 KiB
#include"books.h" #include <bits/stdc++.h> using namespace std; using ll = long long; #define forn(i,n) for(int i=0;i<n;++i) void solve(int n, int k, ll A, int s) { int d=A/k; int l=1, r=n; vector<pair<int,int>> paia; while (l<r) { int mid=(l+r)>>1; int x=skim(mid); if (x<d) l=mid+1; else r=mid; if (r==l) paia.push_back({x,mid}); } for (int i=r-1; i>=max(i-k+1,1); --i) { int x=skim(i); paia.push_back({x,i}); } for (int i=r+1; i<=min(i+k+1,n); ++i) { int x=skim(i); paia.push_back({x,i}); } sort(paia.begin(), paia.end()); for (int m=1; m<(1<<paia.size()); ++m) { int cnt=0; forn(i,paia.size()) cnt+=(m>>i)&1; if (cnt!=k) continue; ll s=0; forn(i,paia.size()) if ((m>>i)&1) s+=paia[i].first; if (s>=A && s<=2*A) { vector<int> ans; forn(i,paia.size()) if ((m>>i)&1) ans.push_back(paia[i].second); answer(ans); return; } } impossible(); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, ll, int)':
books.cpp:5:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define forn(i,n) for(int i=0;i<n;++i)
......
   32 |   forn(i,paia.size()) cnt+=(m>>i)&1;
      |        ~~~~~~~~~~~~~            
books.cpp:32:3: note: in expansion of macro 'forn'
   32 |   forn(i,paia.size()) cnt+=(m>>i)&1;
      |   ^~~~
books.cpp:5:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define forn(i,n) for(int i=0;i<n;++i)
......
   35 |   forn(i,paia.size()) if ((m>>i)&1) s+=paia[i].first;
      |        ~~~~~~~~~~~~~            
books.cpp:35:3: note: in expansion of macro 'forn'
   35 |   forn(i,paia.size()) if ((m>>i)&1) s+=paia[i].first;
      |   ^~~~
books.cpp:5:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define forn(i,n) for(int i=0;i<n;++i)
......
   38 |    forn(i,paia.size()) if ((m>>i)&1) ans.push_back(paia[i].second);
      |         ~~~~~~~~~~~~~           
books.cpp:38:4: note: in expansion of macro 'forn'
   38 |    forn(i,paia.size()) if ((m>>i)&1) ans.push_back(paia[i].second);
      |    ^~~~
#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...