제출 #401226

#제출 시각아이디문제언어결과실행 시간메모리
401226galcaA Difficult(y) Choice (BOI21_books)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <set> using namespace std; #include "sort/books.h" int findA(vector<long long>& books, long long A, int lower, int upper) { if (books[lower] == -1) { books[lower] = skim(lower + 1); } if (books[upper] == -1) { books[upper] = skim(upper + 1); } if (books[lower] > A) { return -1; } if (books[upper] <= A) { return upper; } if (upper - lower < 2) { return lower; } int half = (upper - lower + 1) / 2; books[lower + half] = skim(lower + half + 1); if (books[lower + half] <= A) return findA(books, A, lower + half, upper); else return findA(books, A, lower, lower + half); } void solve(int N, int K, long long A, int S) { if (K > N) { impossible(); return; } vector<long long> books(N); for (int i = 0; i < N; i++) { books[i] = -1; } long long sumFirstK = 0; for (int i = 0; i < K; i++) { if (books[i] == -1) { books[i] = skim(i + 1); } sumFirstK += books[i]; } if (sumFirstK > A * 2) { impossible(); } else { vector<int> res; for (int i = 0; i < K; i++) { res.push_back(i + 1); } if (sumFirstK >= A) { answer(res); } else { // sumFirstK < A // find last element < A long long posA = findA(books, A, 0, N - 1); long long currentSum = sumFirstK; // try to replace smallest with largest for (int i = 0; i < K; i++) { if (books[posA - i] == -1) { books[posA - i] = skim(posA - i + 1); } currentSum -= books[i]; res[i] = posA - i + 1; currentSum += books[posA - i]; if (currentSum >= A) { // check that no book appears twice set<int> validator; for (int j = 0; j < K; j++) { validator.insert(res[j]); } if (validator.size() == K) { answer(res); } else { impossible(); } break; } } // failed to build the sum with elements < A only // need to look at elements > A int i = 0; while ((i < K) && ((posA + 1 + i) < N)) { if (books[posA + i + 1] == -1) { books[posA + i + 1] = skim(posA + i + 2); } sumFirstK -= books[K - i - 1]; res[K - i - 1] = posA + i + 2; sumFirstK += books[posA + i + 1]; if (sumFirstK > A * 2) { impossible(); break; } else { if (sumFirstK >= A) { set<int> validator; for (int j = 0; j < K; j++) { validator.insert(res[j]); } if (validator.size() == K) { answer(res); } else { impossible(); } break; } } } impossible(); } } return; }

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

books.cpp:6:10: fatal error: sort/books.h: No such file or directory
    6 | #include "sort/books.h"
      |          ^~~~~~~~~~~~~~
compilation terminated.