답안 #314508

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314508 2020-10-20T06:57:14 Z anakib1 커다란 상품 (IOI17_prize) C++17
90 / 100
114 ms 416 KB
#include "prize.h"
#include "bits/stdc++.h"
using namespace std;
int find_best(int n){
	int mx = 0;
	for(int i = 0 ; i < 500 ; ++i){
		vector < int > res = ask(i);
		if(res[0] + res[1] == 0){
			return i;
		}
		mx = max(mx , res[0] + res[1]);
	}
	int i = 500;
	while(i < n){
		vector < int > res = ask(i);
		if(res[0] + res[1] == 0){
			return i;
		}
		if(res[0] + res[1] == mx){
			int l = i + 1;
			int r = n - 1;
			while(l < r){
				int mid = l + r >> 1;
				vector < int > tmp = ask(mid);
				if(tmp[0] + tmp[1] == 0){
					return mid;
				}
				if(tmp[0] + tmp[1] < mx){
					r = mid;
				}
				else{
					if(res[1] - tmp[1] > 0){
						r = mid - 1;
					}
					else{
						l = mid + 1;
					}
				}
			}
			res = ask(l);
			if(res[0] + res[1] == 0){
				return l;
			}
			i = l + 1;
		}
		else{
			++i;
		}
	}
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:23:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   23 |     int mid = l + r >> 1;
      |               ~~^~~
prize.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
   50 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 6 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 6 ms 256 KB Output is correct
3 Correct 6 ms 256 KB Output is correct
4 Correct 5 ms 360 KB Output is correct
5 Correct 6 ms 372 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 6 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 9 ms 256 KB Output is correct
12 Correct 6 ms 256 KB Output is correct
13 Correct 8 ms 256 KB Output is correct
14 Correct 8 ms 256 KB Output is correct
15 Correct 16 ms 256 KB Output is correct
16 Partially correct 64 ms 256 KB Partially correct - number of queries: 7575
17 Correct 4 ms 256 KB Output is correct
18 Partially correct 83 ms 256 KB Partially correct - number of queries: 8808
19 Correct 4 ms 256 KB Output is correct
20 Correct 24 ms 256 KB Output is correct
21 Correct 39 ms 256 KB Output is correct
22 Correct 9 ms 256 KB Output is correct
23 Correct 6 ms 256 KB Output is correct
24 Correct 7 ms 256 KB Output is correct
25 Partially correct 44 ms 256 KB Partially correct - number of queries: 5174
26 Partially correct 63 ms 256 KB Partially correct - number of queries: 5113
27 Correct 6 ms 256 KB Output is correct
28 Partially correct 66 ms 256 KB Partially correct - number of queries: 8385
29 Partially correct 71 ms 256 KB Partially correct - number of queries: 6460
30 Partially correct 80 ms 256 KB Partially correct - number of queries: 8742
31 Correct 6 ms 256 KB Output is correct
32 Correct 11 ms 256 KB Output is correct
33 Correct 0 ms 256 KB Output is correct
34 Correct 17 ms 376 KB Output is correct
35 Correct 9 ms 256 KB Output is correct
36 Correct 23 ms 256 KB Output is correct
37 Correct 7 ms 256 KB Output is correct
38 Correct 5 ms 256 KB Output is correct
39 Correct 42 ms 256 KB Output is correct
40 Partially correct 40 ms 256 KB Partially correct - number of queries: 7542
41 Partially correct 42 ms 256 KB Partially correct - number of queries: 5455
42 Partially correct 38 ms 256 KB Partially correct - number of queries: 5455
43 Correct 43 ms 256 KB Output is correct
44 Correct 33 ms 256 KB Output is correct
45 Correct 17 ms 376 KB Output is correct
46 Correct 4 ms 256 KB Output is correct
47 Correct 44 ms 372 KB Output is correct
48 Partially correct 86 ms 256 KB Partially correct - number of queries: 6634
49 Correct 10 ms 256 KB Output is correct
50 Partially correct 95 ms 256 KB Partially correct - number of queries: 8797
51 Correct 46 ms 256 KB Output is correct
52 Correct 5 ms 256 KB Output is correct
53 Correct 9 ms 256 KB Output is correct
54 Correct 51 ms 256 KB Output is correct
55 Correct 6 ms 256 KB Output is correct
56 Partially correct 108 ms 256 KB Partially correct - number of queries: 8797
57 Partially correct 48 ms 256 KB Partially correct - number of queries: 6560
58 Partially correct 56 ms 256 KB Partially correct - number of queries: 6661
59 Partially correct 48 ms 256 KB Partially correct - number of queries: 5455
60 Partially correct 40 ms 256 KB Partially correct - number of queries: 5098
61 Correct 7 ms 256 KB Output is correct
62 Correct 5 ms 256 KB Output is correct
63 Correct 6 ms 416 KB Output is correct
64 Correct 7 ms 256 KB Output is correct
65 Correct 7 ms 256 KB Output is correct
66 Correct 13 ms 256 KB Output is correct
67 Correct 8 ms 256 KB Output is correct
68 Correct 5 ms 256 KB Output is correct
69 Correct 14 ms 256 KB Output is correct
70 Correct 7 ms 256 KB Output is correct
71 Partially correct 106 ms 256 KB Partially correct - number of queries: 8756
72 Correct 10 ms 256 KB Output is correct
73 Partially correct 104 ms 256 KB Partially correct - number of queries: 8648
74 Partially correct 68 ms 256 KB Partially correct - number of queries: 8696
75 Correct 7 ms 256 KB Output is correct
76 Partially correct 61 ms 256 KB Partially correct - number of queries: 7560
77 Partially correct 79 ms 256 KB Partially correct - number of queries: 8823
78 Correct 10 ms 256 KB Output is correct
79 Correct 34 ms 256 KB Output is correct
80 Partially correct 95 ms 256 KB Partially correct - number of queries: 8836
81 Partially correct 71 ms 256 KB Partially correct - number of queries: 8841
82 Partially correct 114 ms 256 KB Partially correct - number of queries: 8737
83 Correct 4 ms 384 KB Output is correct
84 Partially correct 76 ms 256 KB Partially correct - number of queries: 7276
85 Partially correct 89 ms 384 KB Partially correct - number of queries: 8800
86 Correct 5 ms 256 KB Output is correct
87 Correct 5 ms 256 KB Output is correct
88 Correct 6 ms 256 KB Output is correct
89 Correct 4 ms 256 KB Output is correct
90 Correct 6 ms 256 KB Output is correct
91 Correct 7 ms 256 KB Output is correct
92 Correct 5 ms 256 KB Output is correct
93 Correct 12 ms 256 KB Output is correct
94 Correct 9 ms 256 KB Output is correct
95 Correct 9 ms 256 KB Output is correct
96 Correct 11 ms 256 KB Output is correct
97 Correct 6 ms 256 KB Output is correct