제출 #725499

#제출 시각아이디문제언어결과실행 시간메모리
725499josanneo22A Difficult(y) Choice (BOI21_books)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> 
using namespace std;
int arr[200005], arr2[200005];
void solve(int N, int K, long long A, int S) {
	int n = N,  k = K, a = A, s = S;
	for (int i = 1; i <= k; i++) {
		arr[i]=skim(i);
	}
	int mn = 1, mx = n, loc = n + 1;
	long long val = 1e18;
	while (mn <= mx) {
		int mid = (mx + mx) / 2;
		long long tmp = skim(mid);
		if (tmp >= a) {
			val = tmp;
			loc = mid;
			mx = mid - 1;
		}
		else mn = mid + 1;
	}
	if (loc != n + 1) {
		long long sum = 0;
		for (int i = 1; i < k; i++) sum += arr[i];
		sum += val;
		if (A <= sum && sum <= A + A) {
			vector<int> v;
			for (int i = 1; i < k; i++) v.push_back(i);
			v.push_back(loc);
			answer(v);
			return;
		}
	}

	loc--;
	if (loc < k) impossible();

	for (int i = 1; i <= k; i++) {
		arr2[i] = skim(loc + 1 - i);
	}

	for (int i = 0; i <= k; i++) {
		long long sum = 0;
		for (int j = 1; j <= i; j++) sum += arr[j];
		for (int j = 1; j <= k - i; j++) sum += arr2[j];
		if (A <= sum && sum <= A + A) {
			vector<int> v;
			for (int j = 1; j <= i; j++) v.push_back(j);
			for (int j = 1; j <= k - i; j++) v.push_back(loc + 1 - j);
			answer(v);
			return;
		}
	}
	impossible();
}

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:7:10: error: 'skim' was not declared in this scope
    7 |   arr[i]=skim(i);
      |          ^~~~
books.cpp:13:19: error: 'skim' was not declared in this scope
   13 |   long long tmp = skim(mid);
      |                   ^~~~
books.cpp:29:4: error: 'answer' was not declared in this scope
   29 |    answer(v);
      |    ^~~~~~
books.cpp:35:15: error: 'impossible' was not declared in this scope
   35 |  if (loc < k) impossible();
      |               ^~~~~~~~~~
books.cpp:38:13: error: 'skim' was not declared in this scope
   38 |   arr2[i] = skim(loc + 1 - i);
      |             ^~~~
books.cpp:49:4: error: 'answer' was not declared in this scope
   49 |    answer(v);
      |    ^~~~~~
books.cpp:53:2: error: 'impossible' was not declared in this scope
   53 |  impossible();
      |  ^~~~~~~~~~
books.cpp:5:28: warning: unused variable 's' [-Wunused-variable]
    5 |  int n = N,  k = K, a = A, s = S;
      |                            ^