제출 #582133

#제출 시각아이디문제언어결과실행 시간메모리
582133Soumya1A Difficult(y) Choice (BOI21_books)C++17
100 / 100
68 ms336 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; void solve(int n, int k, long long a, int s) { int lo = 1, hi = n; while (lo < hi) { int mid = (lo + hi) >> 1; if (skim(mid) >= a) hi = mid; else lo = mid + 1; } vector<pair<long long, int>> b; for (int i = 1; i <= min(n, 10); i++) b.push_back({skim(i), i}); for (int i = lo; i > max(max(0, lo - 10), min(n, 10)); i--) b.push_back({skim(i), i}); for (int i = 1; i < (1 << b.size()); i++) { long long sum = 0; for (int j = 0; j < b.size(); j++) { if (i & (1 << j)) sum += b[j].first; } if (a <= sum && sum <= 2 * a && __builtin_popcount(i) == k) { vector<int> ans; for (int j = 0; j < b.size(); j++) { if (i & (1 << j)) ans.push_back(b[j].second); } answer(ans); return; } } impossible(); }

컴파일 시 표준 에러 (stderr) 메시지

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:16:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for (int j = 0; j < b.size(); j++) {
      |                     ~~^~~~~~~~~~
books.cpp:21:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |       for (int j = 0; j < b.size(); j++) {
      |                       ~~^~~~~~~~~~
#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...