답안 #137755

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
137755 2019-07-28T09:25:53 Z Mahdi_Jfri 커다란 상품 (IOI17_prize) C++14
90 / 100
104 ms 5504 KB
#include "prize.h"
#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define pb push_back
 
const int maxn = 2e5 + 20;
 
vector<int> res[maxn] , candid;
 
int mx;

bool found;
 
vector<int> reval(int k)
{
	if(!res[k].empty())
		return res[k];
 
	res[k] = ask(k);
	if(res[k][0] + res[k][1] == 0)
		found = 1;
	return res[k];
}
 
void solve(int l , int r)
{
	if(found)
		return;
	while(l < r)
	{
		if(found)
			return;
		auto tmp = reval(l);
		if(tmp[0] + tmp[1] != mx)
			candid.pb(l++);
		else
			break;
	}
	if(found)
		return;
	while(l < r)
	{
		if(found)
			return;
		r--;
		auto tmp = reval(r);
		if(tmp[0] + tmp[1] != mx)
			candid.pb(r);
		else
			break;
	}
	if(found)
		return;
 
	if(l >= r)
		return;
 
	reval(l); reval(r);
	if(res[r][0] - res[l][0] == 0)
		return;
 
	int m = (l + r) / 2;
	solve(m , r + 1);
	solve(l , m);
}
 
int find_best(int n)
{
	if(n <= 5000)
	{
		for(int i = 0; i < n; i++) {
			std::vector<int> res = ask(i);
			if(res[0] + res[1] == 0)
				return i;
		}
	}
 
	for(int i = 0; i < 600; i++)
	{
		vector<int> tmp = reval(i);
		mx = max(mx , tmp[0] + tmp[1]);
	}
 
	solve(0 , n);
 
	for(int i = 0; i < n; i++)
	{
		if(res[i].empty())
			continue;
		auto tmp = res[i];
		if(tmp[0] + tmp[1] == 0)
			return i;
	}
	cout << 1/0;
	return -85;
}
 
 

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:97:11: warning: division by zero [-Wdiv-by-zero]
  cout << 1/0;
          ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 4984 KB Output is correct
2 Correct 14 ms 4984 KB Output is correct
3 Correct 10 ms 5028 KB Output is correct
4 Correct 13 ms 4984 KB Output is correct
5 Correct 10 ms 5152 KB Output is correct
6 Correct 9 ms 5056 KB Output is correct
7 Correct 12 ms 4984 KB Output is correct
8 Correct 15 ms 4988 KB Output is correct
9 Correct 13 ms 5104 KB Output is correct
10 Correct 13 ms 4984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 5116 KB Output is correct
2 Correct 13 ms 4984 KB Output is correct
3 Correct 13 ms 5028 KB Output is correct
4 Correct 12 ms 4984 KB Output is correct
5 Correct 14 ms 4984 KB Output is correct
6 Correct 9 ms 5136 KB Output is correct
7 Correct 12 ms 4984 KB Output is correct
8 Correct 10 ms 5136 KB Output is correct
9 Correct 11 ms 4984 KB Output is correct
10 Correct 9 ms 5028 KB Output is correct
11 Correct 12 ms 5120 KB Output is correct
12 Correct 20 ms 5112 KB Output is correct
13 Correct 13 ms 4984 KB Output is correct
14 Correct 27 ms 5020 KB Output is correct
15 Partially correct 78 ms 5124 KB Partially correct - number of queries: 6718
16 Correct 27 ms 4984 KB Output is correct
17 Correct 11 ms 5112 KB Output is correct
18 Correct 14 ms 4984 KB Output is correct
19 Correct 9 ms 5136 KB Output is correct
20 Correct 52 ms 5112 KB Output is correct
21 Partially correct 66 ms 5180 KB Partially correct - number of queries: 5345
22 Partially correct 60 ms 5300 KB Partially correct - number of queries: 5864
23 Correct 15 ms 5112 KB Output is correct
24 Correct 21 ms 5088 KB Output is correct
25 Correct 49 ms 5008 KB Output is correct
26 Correct 39 ms 5148 KB Output is correct
27 Correct 15 ms 5024 KB Output is correct
28 Correct 18 ms 4984 KB Output is correct
29 Correct 20 ms 5068 KB Output is correct
30 Correct 13 ms 5240 KB Output is correct
31 Correct 16 ms 5112 KB Output is correct
32 Correct 11 ms 5116 KB Output is correct
33 Correct 7 ms 4984 KB Output is correct
34 Partially correct 38 ms 5296 KB Partially correct - number of queries: 5830
35 Correct 14 ms 5032 KB Output is correct
36 Partially correct 70 ms 5168 KB Partially correct - number of queries: 6435
37 Correct 23 ms 4984 KB Output is correct
38 Correct 11 ms 5136 KB Output is correct
39 Correct 53 ms 5112 KB Output is correct
40 Correct 13 ms 5112 KB Output is correct
41 Correct 40 ms 5060 KB Output is correct
42 Correct 46 ms 5116 KB Output is correct
43 Correct 37 ms 5292 KB Output is correct
44 Partially correct 39 ms 5280 KB Partially correct - number of queries: 5247
45 Partially correct 35 ms 5284 KB Partially correct - number of queries: 5293
46 Correct 15 ms 4984 KB Output is correct
47 Correct 43 ms 5152 KB Output is correct
48 Correct 37 ms 5096 KB Output is correct
49 Partially correct 82 ms 5288 KB Partially correct - number of queries: 7614
50 Correct 10 ms 5136 KB Output is correct
51 Partially correct 62 ms 5084 KB Partially correct - number of queries: 5245
52 Partially correct 89 ms 5240 KB Partially correct - number of queries: 8107
53 Correct 14 ms 5012 KB Output is correct
54 Correct 61 ms 5112 KB Output is correct
55 Correct 12 ms 4984 KB Output is correct
56 Correct 15 ms 4984 KB Output is correct
57 Correct 36 ms 5120 KB Output is correct
58 Correct 22 ms 5176 KB Output is correct
59 Correct 50 ms 5112 KB Output is correct
60 Correct 44 ms 5096 KB Output is correct
61 Correct 13 ms 4984 KB Output is correct
62 Correct 16 ms 4984 KB Output is correct
63 Correct 14 ms 4984 KB Output is correct
64 Correct 13 ms 5112 KB Output is correct
65 Correct 13 ms 5112 KB Output is correct
66 Correct 13 ms 5112 KB Output is correct
67 Correct 17 ms 4984 KB Output is correct
68 Correct 9 ms 5140 KB Output is correct
69 Correct 12 ms 5024 KB Output is correct
70 Correct 13 ms 5028 KB Output is correct
71 Partially correct 101 ms 5288 KB Partially correct - number of queries: 9636
72 Correct 20 ms 5112 KB Output is correct
73 Partially correct 96 ms 5308 KB Partially correct - number of queries: 9517
74 Partially correct 104 ms 5288 KB Partially correct - number of queries: 9568
75 Correct 13 ms 4984 KB Output is correct
76 Partially correct 88 ms 5504 KB Partially correct - number of queries: 8412
77 Partially correct 95 ms 5368 KB Partially correct - number of queries: 9073
78 Correct 20 ms 4988 KB Output is correct
79 Correct 58 ms 5112 KB Output is correct
80 Partially correct 57 ms 5296 KB Partially correct - number of queries: 9046
81 Partially correct 74 ms 5376 KB Partially correct - number of queries: 9064
82 Partially correct 73 ms 5240 KB Partially correct - number of queries: 8946
83 Correct 16 ms 4984 KB Output is correct
84 Partially correct 52 ms 5300 KB Partially correct - number of queries: 7602
85 Partially correct 95 ms 5468 KB Partially correct - number of queries: 9005
86 Correct 15 ms 5116 KB Output is correct
87 Correct 12 ms 5028 KB Output is correct
88 Correct 14 ms 4984 KB Output is correct
89 Correct 15 ms 5032 KB Output is correct
90 Correct 11 ms 4984 KB Output is correct
91 Correct 13 ms 4984 KB Output is correct
92 Correct 14 ms 4984 KB Output is correct
93 Correct 14 ms 5136 KB Output is correct
94 Correct 21 ms 4984 KB Output is correct
95 Correct 17 ms 4984 KB Output is correct
96 Correct 18 ms 4984 KB Output is correct
97 Correct 15 ms 5112 KB Output is correct