제출 #726855

#제출 시각아이디문제언어결과실행 시간메모리
726855finn__A Difficult(y) Choice (BOI21_books)C++17
100 / 100
2 ms420 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; constexpr size_t N = 100001; long long cache[N]; long long query(int i) { return cache[i] ? cache[i] : cache[i] = skim(i); } void solve(int N, int K, long long A, int S) { int a = 1, b = N; while (a < b) { int mid = (a + b) / 2; if (query(mid) <= A) a = mid + 1; else b = mid; } long long sum = 0; for (size_t i = 1; i < K; ++i) sum += query(i); if (query(a) <= A) ++a; if (a <= N && query(a) + sum <= 2 * A) { vector<int> v(K); iota(v.begin(), v.begin() + K - 1, 1); v.back() = a; answer(v); } sum += query(K); if (A <= sum && sum <= 2 * A) { vector<int> v(K); iota(v.begin(), v.end(), 1); answer(v); } if (2 * K >= a) { for (size_t i = K + 1; i < a; ++i) { sum -= query(i - K); sum += query(i); if (A <= sum && sum <= 2 * A) { vector<int> v; iota(v.begin(), v.end(), i - K + 1); answer(v); } } } else { for (size_t i = 0; i < K; ++i) { sum -= query(K - i); sum += query(a - K + i); if (A <= sum && sum <= 2 * A) { vector<int> v(K); iota(v.begin(), v.begin() + K - i - 1, 1); iota(v.begin() + K - i - 1, v.end(), a - K); answer(v); } } } impossible(); }

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:23:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |     for (size_t i = 1; i < K; ++i)
      |                        ~~^~~
books.cpp:43:34: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |         for (size_t i = K + 1; i < a; ++i)
      |                                ~~^~~
books.cpp:57:30: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |         for (size_t i = 0; i < K; ++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...