답안 #328286

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
328286 2020-11-16T05:12:27 Z arnold518 커다란 상품 (IOI17_prize) C++14
90 / 100
114 ms 2028 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2e5;

int N;
pii M[MAXN+10];

pii query(int x)
{
	if(M[x]!=pii(-1, -1)) return M[x];
	vector<int> res=ask(x-1);
	return M[x]=pii(res[0], res[1]);
}

int find_best(int _N)
{
	N=_N;
	for(int i=1; i<=N; i++) M[i]=pii(-1, -1);

	int t=0;
	for(int i=1; i<=min(720, N); i++)
	{
		pii p=query(i);
		t=max(t, p.first+p.second);
	}

	for(int i=1; i<=N;)
	{
		pii p=query(i);
		if(p.first==0 && p.second==0) return i-1;
		if(p.first+p.second==t)
		{
			int lo=i, hi=N+1;
			while(lo+1<hi)
			{
				int mid=lo+hi>>1;
				if(query(mid).second==p.second) lo=mid;
				else hi=mid;
			}
			i=hi;
		}
		else
		{
			i++;
		}
	}
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:42:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   42 |     int mid=lo+hi>>1;
      |             ~~^~~
prize.cpp:53:1: warning: control reaches end of non-void function [-Wreturn-type]
   53 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1900 KB Output is correct
2 Correct 10 ms 1900 KB Output is correct
3 Correct 5 ms 2028 KB Output is correct
4 Correct 7 ms 1900 KB Output is correct
5 Correct 9 ms 1900 KB Output is correct
6 Correct 8 ms 1900 KB Output is correct
7 Correct 8 ms 1900 KB Output is correct
8 Correct 5 ms 2028 KB Output is correct
9 Correct 11 ms 1900 KB Output is correct
10 Correct 10 ms 1900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1900 KB Output is correct
2 Correct 11 ms 1900 KB Output is correct
3 Correct 8 ms 1900 KB Output is correct
4 Correct 9 ms 1900 KB Output is correct
5 Correct 11 ms 1900 KB Output is correct
6 Correct 11 ms 1900 KB Output is correct
7 Correct 8 ms 1900 KB Output is correct
8 Correct 12 ms 1900 KB Output is correct
9 Correct 9 ms 1900 KB Output is correct
10 Correct 9 ms 1900 KB Output is correct
11 Correct 8 ms 2028 KB Output is correct
12 Correct 11 ms 1900 KB Output is correct
13 Correct 28 ms 1900 KB Output is correct
14 Correct 13 ms 492 KB Output is correct
15 Correct 24 ms 1900 KB Output is correct
16 Partially correct 71 ms 1900 KB Partially correct - number of queries: 7457
17 Correct 6 ms 2028 KB Output is correct
18 Partially correct 58 ms 2028 KB Partially correct - number of queries: 8596
19 Correct 10 ms 1900 KB Output is correct
20 Correct 25 ms 1132 KB Output is correct
21 Correct 43 ms 1900 KB Output is correct
22 Correct 13 ms 1900 KB Output is correct
23 Correct 5 ms 2028 KB Output is correct
24 Correct 11 ms 1900 KB Output is correct
25 Partially correct 49 ms 1900 KB Partially correct - number of queries: 5155
26 Partially correct 51 ms 1900 KB Partially correct - number of queries: 5080
27 Correct 10 ms 1900 KB Output is correct
28 Partially correct 114 ms 1900 KB Partially correct - number of queries: 8118
29 Partially correct 63 ms 1900 KB Partially correct - number of queries: 6341
30 Partially correct 85 ms 1900 KB Partially correct - number of queries: 8554
31 Correct 10 ms 1900 KB Output is correct
32 Correct 15 ms 1900 KB Output is correct
33 Correct 2 ms 364 KB Output is correct
34 Correct 40 ms 2028 KB Output is correct
35 Correct 10 ms 1900 KB Output is correct
36 Correct 25 ms 1900 KB Output is correct
37 Correct 10 ms 1900 KB Output is correct
38 Correct 8 ms 1900 KB Output is correct
39 Correct 44 ms 1900 KB Output is correct
40 Partially correct 71 ms 1900 KB Partially correct - number of queries: 7439
41 Partially correct 59 ms 1900 KB Partially correct - number of queries: 5444
42 Partially correct 66 ms 1912 KB Partially correct - number of queries: 5444
43 Correct 41 ms 1900 KB Output is correct
44 Correct 24 ms 2028 KB Output is correct
45 Correct 40 ms 1900 KB Output is correct
46 Correct 5 ms 2028 KB Output is correct
47 Correct 55 ms 1900 KB Output is correct
48 Partially correct 61 ms 1900 KB Partially correct - number of queries: 6561
49 Correct 14 ms 1900 KB Output is correct
50 Partially correct 103 ms 1900 KB Partially correct - number of queries: 8599
51 Correct 38 ms 1900 KB Output is correct
52 Correct 12 ms 1900 KB Output is correct
53 Correct 13 ms 1912 KB Output is correct
54 Correct 53 ms 1900 KB Output is correct
55 Correct 9 ms 1900 KB Output is correct
56 Partially correct 98 ms 1900 KB Partially correct - number of queries: 8599
57 Partially correct 36 ms 1900 KB Partially correct - number of queries: 6475
58 Partially correct 78 ms 1900 KB Partially correct - number of queries: 6549
59 Partially correct 54 ms 1900 KB Partially correct - number of queries: 5440
60 Partially correct 44 ms 1900 KB Partially correct - number of queries: 5082
61 Correct 8 ms 1900 KB Output is correct
62 Correct 11 ms 1900 KB Output is correct
63 Correct 12 ms 1900 KB Output is correct
64 Correct 9 ms 1900 KB Output is correct
65 Correct 8 ms 1900 KB Output is correct
66 Correct 13 ms 1900 KB Output is correct
67 Correct 8 ms 1904 KB Output is correct
68 Correct 8 ms 1900 KB Output is correct
69 Correct 16 ms 1900 KB Output is correct
70 Correct 7 ms 1912 KB Output is correct
71 Partially correct 81 ms 1900 KB Partially correct - number of queries: 8472
72 Correct 15 ms 1900 KB Output is correct
73 Partially correct 70 ms 1900 KB Partially correct - number of queries: 8365
74 Partially correct 109 ms 1900 KB Partially correct - number of queries: 8403
75 Correct 12 ms 1900 KB Output is correct
76 Partially correct 54 ms 1900 KB Partially correct - number of queries: 7317
77 Partially correct 108 ms 1900 KB Partially correct - number of queries: 8645
78 Correct 18 ms 1932 KB Output is correct
79 Correct 35 ms 1900 KB Output is correct
80 Partially correct 75 ms 1900 KB Partially correct - number of queries: 8634
81 Partially correct 98 ms 1900 KB Partially correct - number of queries: 8611
82 Partially correct 105 ms 1900 KB Partially correct - number of queries: 8529
83 Correct 9 ms 1900 KB Output is correct
84 Partially correct 94 ms 1912 KB Partially correct - number of queries: 7160
85 Partially correct 47 ms 1932 KB Partially correct - number of queries: 8619
86 Correct 10 ms 1900 KB Output is correct
87 Correct 11 ms 1900 KB Output is correct
88 Correct 9 ms 1900 KB Output is correct
89 Correct 8 ms 1900 KB Output is correct
90 Correct 9 ms 1900 KB Output is correct
91 Correct 11 ms 1900 KB Output is correct
92 Correct 9 ms 1900 KB Output is correct
93 Correct 14 ms 1900 KB Output is correct
94 Correct 12 ms 1900 KB Output is correct
95 Correct 9 ms 1900 KB Output is correct
96 Correct 16 ms 1900 KB Output is correct
97 Correct 12 ms 1900 KB Output is correct