답안 #259192

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
259192 2020-08-07T10:55:10 Z GREGOIRELC 커다란 상품 (IOI17_prize) C++14
90 / 100
120 ms 1624 KB
#include "prize.h"
#include <iostream>

using namespace std;

const int MAX_CADEAU = 2e5;
const int MAX_UTILE = 500;

bool estUtile[MAX_CADEAU];
bool dejaVu[MAX_CADEAU];
int resultGauche[MAX_CADEAU];

int find_best(int N)
{
	int maxi = 0;
	for(int iCadeau = 0; iCadeau < min(MAX_UTILE, N); iCadeau++)
	{
		vector<int> r = ask(iCadeau);
		maxi = max(maxi, r[0] + r[1]);
	}

	int curCadeau = 0;
	vector<int> r = ask(N - 1);
	if(r[0] + r[1] < maxi)
	{
		estUtile[N - 1] = true;
	}
	dejaVu[N - 1] = true;
	resultGauche[N - 1] = r[0];
	while(curCadeau < N)
	{
		if(estUtile[curCadeau])
		{
			curCadeau++;
			continue;
		}
		vector<int> r;
		int nbGauche;
		if(dejaVu[curCadeau])
		{
			nbGauche = resultGauche[curCadeau];
		}
		else
		{
			r = ask(curCadeau);
			if(r[0] + r[1] < maxi)
			{
				estUtile[curCadeau] = true;
				curCadeau++;
				continue;
			}
			dejaVu[curCadeau] = true;
			resultGauche[curCadeau] = r[0];
			nbGauche = r[0];
		}
		int borneGauche = curCadeau, borneDroite = N - 1;
		while(borneGauche < borneDroite - 1)
		{
			//cout << borneGauche << " " << borneDroite << endl;
			int mid = (borneGauche + borneDroite) / 2;
			if(estUtile[mid])
			{
				borneDroite = mid;
			}
			else if(dejaVu[mid])
			{
				if(resultGauche[mid] == nbGauche)
				{
					borneGauche = mid;
				}
				else
				{
					borneDroite = mid;
				}
			}
			else
			{
				r = ask(mid);
				dejaVu[mid] = true;
				resultGauche[mid] = r[0];
				if(r[0] + r[1] < maxi)
				{
					estUtile[mid] = true;
					borneDroite = mid;
				}
				else if(r[0] > nbGauche)
				{
					borneDroite = mid;
				}
				else
				{
					borneGauche = mid;
				}
			}
		}
		//cout << borneGauche << " " << borneDroite << endl;
		if(!estUtile[borneDroite] && resultGauche[borneDroite] == nbGauche)
		{
			curCadeau = borneDroite + 1;
		}
		else
		{
			curCadeau = borneGauche + 1;
		}
	}

	for(int curCadeau = 0; curCadeau < N; curCadeau++)
	{
		if(estUtile[curCadeau])
		{
			vector<int> r = ask(curCadeau);
			if(r[0] + r[1] == 0)
			{
				return curCadeau;
			}
		}
	}
	return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 11 ms 376 KB Output is correct
4 Correct 9 ms 376 KB Output is correct
5 Correct 6 ms 392 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 8 ms 384 KB Output is correct
10 Correct 9 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 7 ms 384 KB Output is correct
6 Correct 7 ms 384 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 9 ms 376 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 11 ms 1280 KB Output is correct
12 Correct 11 ms 1272 KB Output is correct
13 Correct 15 ms 1276 KB Output is correct
14 Correct 21 ms 508 KB Output is correct
15 Partially correct 78 ms 1528 KB Partially correct - number of queries: 8068
16 Partially correct 116 ms 1528 KB Partially correct - number of queries: 8816
17 Partially correct 110 ms 1532 KB Partially correct - number of queries: 8395
18 Partially correct 111 ms 1528 KB Partially correct - number of queries: 8873
19 Partially correct 61 ms 1528 KB Partially correct - number of queries: 7922
20 Partially correct 59 ms 1100 KB Partially correct - number of queries: 5753
21 Partially correct 68 ms 1528 KB Partially correct - number of queries: 8488
22 Partially correct 66 ms 1528 KB Partially correct - number of queries: 6344
23 Correct 9 ms 720 KB Output is correct
24 Correct 10 ms 1144 KB Output is correct
25 Partially correct 108 ms 1528 KB Partially correct - number of queries: 8582
26 Partially correct 86 ms 1528 KB Partially correct - number of queries: 8506
27 Correct 4 ms 688 KB Output is correct
28 Partially correct 82 ms 1472 KB Partially correct - number of queries: 8648
29 Partially correct 40 ms 1528 KB Partially correct - number of queries: 7129
30 Partially correct 70 ms 1536 KB Partially correct - number of queries: 8826
31 Partially correct 89 ms 1504 KB Partially correct - number of queries: 8370
32 Correct 23 ms 1276 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Partially correct 78 ms 1512 KB Partially correct - number of queries: 8523
35 Correct 11 ms 888 KB Output is correct
36 Partially correct 108 ms 1472 KB Partially correct - number of queries: 8403
37 Correct 6 ms 1104 KB Output is correct
38 Correct 8 ms 632 KB Output is correct
39 Partially correct 78 ms 1588 KB Partially correct - number of queries: 8559
40 Partially correct 62 ms 1476 KB Partially correct - number of queries: 7641
41 Partially correct 60 ms 1532 KB Partially correct - number of queries: 8528
42 Partially correct 70 ms 1528 KB Partially correct - number of queries: 8528
43 Partially correct 39 ms 1524 KB Partially correct - number of queries: 8126
44 Partially correct 41 ms 1536 KB Partially correct - number of queries: 8566
45 Partially correct 90 ms 1624 KB Partially correct - number of queries: 8469
46 Partially correct 105 ms 1540 KB Partially correct - number of queries: 8389
47 Partially correct 106 ms 1460 KB Partially correct - number of queries: 8602
48 Partially correct 58 ms 1536 KB Partially correct - number of queries: 8741
49 Partially correct 112 ms 1528 KB Partially correct - number of queries: 8394
50 Partially correct 115 ms 1528 KB Partially correct - number of queries: 8876
51 Partially correct 115 ms 1528 KB Partially correct - number of queries: 8541
52 Partially correct 63 ms 1576 KB Partially correct - number of queries: 8419
53 Correct 4 ms 700 KB Output is correct
54 Partially correct 75 ms 1412 KB Partially correct - number of queries: 8531
55 Partially correct 52 ms 1532 KB Partially correct - number of queries: 8411
56 Partially correct 69 ms 1532 KB Partially correct - number of queries: 8871
57 Partially correct 71 ms 1528 KB Partially correct - number of queries: 8662
58 Partially correct 65 ms 1528 KB Partially correct - number of queries: 8707
59 Partially correct 74 ms 1528 KB Partially correct - number of queries: 8528
60 Partially correct 65 ms 1532 KB Partially correct - number of queries: 8155
61 Correct 8 ms 632 KB Output is correct
62 Correct 4 ms 700 KB Output is correct
63 Correct 4 ms 700 KB Output is correct
64 Correct 9 ms 632 KB Output is correct
65 Correct 5 ms 384 KB Output is correct
66 Correct 15 ms 380 KB Output is correct
67 Correct 14 ms 376 KB Output is correct
68 Correct 23 ms 376 KB Output is correct
69 Correct 20 ms 436 KB Output is correct
70 Correct 11 ms 376 KB Output is correct
71 Partially correct 120 ms 1528 KB Partially correct - number of queries: 8726
72 Correct 16 ms 1272 KB Output is correct
73 Partially correct 78 ms 1528 KB Partially correct - number of queries: 8589
74 Partially correct 68 ms 1528 KB Partially correct - number of queries: 8665
75 Correct 7 ms 768 KB Output is correct
76 Partially correct 39 ms 1544 KB Partially correct - number of queries: 7538
77 Partially correct 64 ms 1528 KB Partially correct - number of queries: 8901
78 Correct 10 ms 1280 KB Output is correct
79 Correct 32 ms 1528 KB Output is correct
80 Partially correct 80 ms 1528 KB Partially correct - number of queries: 8907
81 Partially correct 107 ms 1528 KB Partially correct - number of queries: 8885
82 Partially correct 79 ms 1528 KB Partially correct - number of queries: 8821
83 Correct 7 ms 640 KB Output is correct
84 Partially correct 57 ms 1528 KB Partially correct - number of queries: 7371
85 Partially correct 76 ms 1564 KB Partially correct - number of queries: 8896
86 Correct 20 ms 384 KB Output is correct
87 Correct 8 ms 384 KB Output is correct
88 Correct 12 ms 384 KB Output is correct
89 Correct 20 ms 384 KB Output is correct
90 Correct 4 ms 384 KB Output is correct
91 Correct 10 ms 384 KB Output is correct
92 Correct 12 ms 504 KB Output is correct
93 Correct 26 ms 1016 KB Output is correct
94 Correct 23 ms 1016 KB Output is correct
95 Correct 25 ms 1016 KB Output is correct
96 Correct 15 ms 1016 KB Output is correct
97 Correct 18 ms 512 KB Output is correct