제출 #849579

#제출 시각아이디문제언어결과실행 시간메모리
849579ieeA Difficult(y) Choice (BOI21_books)C++17
100 / 100
21 ms1996 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; // // --- Sample implementation for the task books --- // // To compile this program with the sample grader, place: // books.h books_sample.cpp sample_grader.cpp // in a single folder and run: // g++ books_sample.cpp sample_grader.cpp // in this folder. // void solve(int N, int K, long long A, int S) { vector<int> av; for (int i = 1; i <= N; i++) { av.push_back(i); } vector<long long> mem(N + 1, -1); auto query = [&](int x) { if (mem[x] != -1) return mem[x]; return mem[x] = skim(x); }; long long sm = 0; for (int i = 1; i < K; i++) { sm += query(i); } int l = K, r = N; while (l < r) { int mid = (l + r + 1) >> 1; if (query(mid) + sm <= A * 2) l = mid; else r = mid - 1; } vector<int> p; for (int i = 1; i < K; i++) { p.push_back(i); } for (int i = l - K + 1; i <= l; i++) { p.push_back(i); } sort(p.begin(), p.end()), p.erase(unique(p.begin(), p.end()), p.end()); for (int s = 0; s < (1 << p.size()); s++) { if (__builtin_popcount(s) == K) { long long sum = 0; vector<int> v; for (int i = 0; i < p.size(); i++) { if (s >> i & 1) { sum += query(p[i]); v.push_back(p[i]); } } if (sum >= A && sum <= A * 2) { answer(v); } } } impossible(); }

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

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