제출 #406190

#제출 시각아이디문제언어결과실행 시간메모리
406190shenxyA Difficult(y) Choice (BOI21_books)C++17
100 / 100
3 ms272 KiB
#include "books.h" #include <algorithm> #include <vector> using namespace std; /*long long skim(int i){return i;} void answer(vector<int> v){} void impossible(){}*/ void solve(int N, int K, long long A, int S) { if (skim(1) > A) impossible(); int l = 1, r = N; while (l != r) { if (skim((l + r) / 2 + 1) <= A) l = (l + r) / 2 + 1; else r = (l + r) / 2; } vector<long long> x, pos; if (r <= 2 * K) { for (int i = 1; i <= r; ++i) pos.push_back(i), x.push_back(skim(i)); } else { for (int i = 1; i <= K; ++i) pos.push_back(i), x.push_back(skim(i)); for (int i = r - K + 1; i <= r; ++i) pos.push_back(i), x.push_back(skim(i)); } if (r != N && r >= K - 1) { long long sum = 0; for (int i = 0; i < K - 1; ++i) sum += x[i]; sum += skim(r + 1); if (sum <= 2 * A) { vector<int> ans; for (int i = 1; i < K; ++i) ans.push_back(i); ans.push_back(r + 1); answer(ans); } } if (r < K) impossible(); long long sum = 0; for (int i = 0; i < K; ++i) sum += x[i]; if (sum > 2 * A) impossible(); if (sum >= A) { vector<int> ans; for (int i = 1; i <= K; ++i) ans.push_back(i); answer(ans); } for (int i = K; i < x.size(); ++i) { sum += x[i] - x[i - K]; if (sum >= A) { vector<int> ans; for (int j = i; j > i - K; --j) ans.push_back(pos[j]); answer(ans); } } impossible(); }

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:42:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for (int i = K; i < x.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...