제출 #787767

#제출 시각아이디문제언어결과실행 시간메모리
787767fabijan_cikacA Difficult(y) Choice (BOI21_books)C++17
100 / 100
29 ms296 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; #define pp pair<int, ll> #define F first #define S second #define ll long long #define pb push_back void solve(int N, int K, ll A, int S){ int l = 1, r = N; while (l < r){ int mid = (l + r - 1) / 2; if (skim(mid) >= A) r = mid; else l = mid + 1; } vector<pp> v; for (int i = 1; i <= l; ++i){ if (i <= K || i >= l - K) v.pb({i, skim(i)}); } for (int i = 0; i < (1 << (int)(v.size())); ++i){ if (__builtin_popcount(i) != K) continue; ll sum = 0; for (int j = 0; j < v.size(); ++j){ if (i & (1 << j)) sum += v[j].S; } if (sum >= A && sum <= 2 * A){ vector<int> ans; for (int j = 0; j < v.size(); ++j){ if (i & (1 << j)) ans.pb(v[j].F); } sort(ans.begin(), ans.end()); answer(ans); } } impossible(); }

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

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