Submission #463965

#TimeUsernameProblemLanguageResultExecution timeMemory
463965MahdiBahramianA Difficult(y) Choice (BOI21_books)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include<books.h>
#define pb push_back
#define F first
#define S second
#define mk make_pair
#define mt make_tuple
using namespace std;
ll ARR[Max]; bool ASK[Max];
int GET(int i)
{
	if(ASK[i]) return ARR[i];
	AKS[i] = 1;
	return ARR[i] = skim(i);
}
ll SUM(int l , int r)
{
	ll ans = 0;
	for(int i = l ; i <= r ; i++) anS += GET(i);
	return ans;
}
void solve(int N , int K , ll A , int S)
{
	ll cur = 0;
	for(int i = 1 ; i < K ; i++) cur += GET(i);
	if(cur + GET(K) > 2 * A) return impossible();
	if(cur + GET(K) >= A)
	{
		vector<int> res; for(int i = 1 ; i <= K ; i++) res.pb(i);
		return answer(res);
	}

	int l = 0 , r = N + 1;
	while(r - l > 1)
	{
		int md = (l + r) >> 1;
		if(cur + GET(md) >= A) r = md;
		else l = md;
	}
	
	if(cur + GET(r) <= 2 * A)
	{
		vector<int> res; for(int i = 1 ; i < K ; i++) res.pb(i);
		return answer(res);
	}
	for(int ln = K - 1 ; ln >= 0 ; ln--)
	{
		if(SUM(1 , ln) + SUM(l - K + ln + 1 , l) >= A)
		{
			vector<int> res;
			for(int i = 1 ; i <= ln ; i++) res.pb(i);
			for(int i = l - K + ln + 1 ; i <= K ; i++) res.pb(i);
			return answer(res);
		}
	}
	return impossible();
}

Compilation message (stderr)

books.cpp:9:1: error: 'll' does not name a type
    9 | ll ARR[Max]; bool ASK[Max];
      | ^~
books.cpp:9:23: error: 'Max' was not declared in this scope
    9 | ll ARR[Max]; bool ASK[Max];
      |                       ^~~
books.cpp: In function 'int GET(int)':
books.cpp:12:5: error: 'ASK' was not declared in this scope
   12 |  if(ASK[i]) return ARR[i];
      |     ^~~
books.cpp:12:20: error: 'ARR' was not declared in this scope
   12 |  if(ASK[i]) return ARR[i];
      |                    ^~~
books.cpp:13:2: error: 'AKS' was not declared in this scope
   13 |  AKS[i] = 1;
      |  ^~~
books.cpp:14:9: error: 'ARR' was not declared in this scope
   14 |  return ARR[i] = skim(i);
      |         ^~~
books.cpp: At global scope:
books.cpp:16:1: error: 'll' does not name a type
   16 | ll SUM(int l , int r)
      | ^~
books.cpp:22:28: error: 'll' has not been declared
   22 | void solve(int N , int K , ll A , int S)
      |                            ^~
books.cpp: In function 'void solve(int, int, int, int)':
books.cpp:24:2: error: 'll' was not declared in this scope
   24 |  ll cur = 0;
      |  ^~
books.cpp:25:31: error: 'cur' was not declared in this scope
   25 |  for(int i = 1 ; i < K ; i++) cur += GET(i);
      |                               ^~~
books.cpp:26:5: error: 'cur' was not declared in this scope
   26 |  if(cur + GET(K) > 2 * A) return impossible();
      |     ^~~
books.cpp:27:5: error: 'cur' was not declared in this scope
   27 |  if(cur + GET(K) >= A)
      |     ^~~
books.cpp:37:6: error: 'cur' was not declared in this scope
   37 |   if(cur + GET(md) >= A) r = md;
      |      ^~~
books.cpp:41:5: error: 'cur' was not declared in this scope
   41 |  if(cur + GET(r) <= 2 * A)
      |     ^~~
books.cpp:48:6: error: 'SUM' was not declared in this scope
   48 |   if(SUM(1 , ln) + SUM(l - K + ln + 1 , l) >= A)
      |      ^~~