답안 #249847

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
249847 2020-07-16T05:04:08 Z srvlt 커다란 상품 (IOI17_prize) C++14
90 / 100
82 ms 5408 KB
#include "prize.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vector <int> v, a[200003];
int N, mx = -1, val = -1, cur = -1, have = 0;

int find_next() {
	int l = cur, r = N;
	while (l < r - 1) {
		int mid = l + r >> 1;
		v = ask(mid);
		if (v[0] + v[1] == val && v[0] == have) l = mid;
		else r = mid;
		a[mid] = v;
	}
	assert(r != N);
	return r;
}

int find_best(int n) {
	N = n;
	for (int i = 0; i < min(n, 500); i++) {
		v = ask(i);
		if (mx == -1 || val < v[0] + v[1]) {
			mx = i, val = v[0] + v[1];
		}
	}
	while (true) {
		cur = find_next();
		have++;
		if (a[cur][0] == 0 && a[cur][1] == 0) return cur;
	}
}

Compilation message

prize.cpp: In function 'int find_next()':
prize.cpp:21:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = l + r >> 1;
             ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4992 KB Output is correct
2 Correct 7 ms 5112 KB Output is correct
3 Correct 6 ms 5120 KB Output is correct
4 Correct 5 ms 5112 KB Output is correct
5 Correct 8 ms 4992 KB Output is correct
6 Correct 7 ms 4992 KB Output is correct
7 Correct 7 ms 4992 KB Output is correct
8 Correct 10 ms 4992 KB Output is correct
9 Correct 6 ms 5120 KB Output is correct
10 Correct 9 ms 4992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5120 KB Output is correct
2 Correct 8 ms 4992 KB Output is correct
3 Correct 8 ms 4992 KB Output is correct
4 Correct 8 ms 4992 KB Output is correct
5 Correct 7 ms 4992 KB Output is correct
6 Correct 8 ms 4992 KB Output is correct
7 Correct 7 ms 4992 KB Output is correct
8 Correct 6 ms 5120 KB Output is correct
9 Correct 6 ms 5064 KB Output is correct
10 Correct 8 ms 4992 KB Output is correct
11 Correct 10 ms 4992 KB Output is correct
12 Correct 8 ms 4992 KB Output is correct
13 Correct 13 ms 4992 KB Output is correct
14 Correct 10 ms 4992 KB Output is correct
15 Correct 18 ms 4992 KB Output is correct
16 Partially correct 49 ms 5392 KB Partially correct - number of queries: 7049
17 Correct 10 ms 4992 KB Output is correct
18 Partially correct 76 ms 5240 KB Partially correct - number of queries: 8169
19 Correct 8 ms 4992 KB Output is correct
20 Correct 22 ms 5112 KB Output is correct
21 Correct 34 ms 5136 KB Output is correct
22 Correct 13 ms 4992 KB Output is correct
23 Correct 7 ms 4992 KB Output is correct
24 Correct 8 ms 4992 KB Output is correct
25 Correct 40 ms 5112 KB Output is correct
26 Correct 41 ms 5112 KB Output is correct
27 Correct 11 ms 4992 KB Output is correct
28 Partially correct 60 ms 5240 KB Partially correct - number of queries: 7824
29 Partially correct 33 ms 5408 KB Partially correct - number of queries: 6045
30 Partially correct 72 ms 5240 KB Partially correct - number of queries: 8100
31 Correct 8 ms 4992 KB Output is correct
32 Correct 11 ms 4992 KB Output is correct
33 Correct 4 ms 4992 KB Output is correct
34 Correct 29 ms 5112 KB Output is correct
35 Correct 12 ms 4992 KB Output is correct
36 Correct 23 ms 5112 KB Output is correct
37 Correct 7 ms 5120 KB Output is correct
38 Correct 9 ms 4992 KB Output is correct
39 Correct 23 ms 5164 KB Output is correct
40 Partially correct 56 ms 5240 KB Partially correct - number of queries: 6991
41 Partially correct 41 ms 5112 KB Partially correct - number of queries: 5109
42 Partially correct 41 ms 5112 KB Partially correct - number of queries: 5109
43 Correct 41 ms 5112 KB Output is correct
44 Correct 39 ms 5064 KB Output is correct
45 Correct 18 ms 5196 KB Output is correct
46 Correct 8 ms 4992 KB Output is correct
47 Correct 25 ms 5232 KB Output is correct
48 Partially correct 59 ms 5240 KB Partially correct - number of queries: 6189
49 Correct 13 ms 4992 KB Output is correct
50 Partially correct 73 ms 5240 KB Partially correct - number of queries: 8163
51 Correct 39 ms 5112 KB Output is correct
52 Correct 7 ms 5072 KB Output is correct
53 Correct 9 ms 4992 KB Output is correct
54 Correct 33 ms 5112 KB Output is correct
55 Correct 8 ms 4992 KB Output is correct
56 Partially correct 73 ms 5240 KB Partially correct - number of queries: 8162
57 Partially correct 52 ms 5244 KB Partially correct - number of queries: 6112
58 Partially correct 50 ms 5308 KB Partially correct - number of queries: 6206
59 Partially correct 39 ms 5112 KB Partially correct - number of queries: 5109
60 Correct 38 ms 5112 KB Output is correct
61 Correct 9 ms 4992 KB Output is correct
62 Correct 7 ms 4992 KB Output is correct
63 Correct 9 ms 4992 KB Output is correct
64 Correct 9 ms 5056 KB Output is correct
65 Correct 11 ms 4992 KB Output is correct
66 Correct 36 ms 4992 KB Output is correct
67 Correct 7 ms 4992 KB Output is correct
68 Partially correct 67 ms 5112 KB Partially correct - number of queries: 8099
69 Correct 34 ms 4992 KB Output is correct
70 Correct 9 ms 4992 KB Output is correct
71 Partially correct 63 ms 5240 KB Partially correct - number of queries: 8301
72 Correct 14 ms 4992 KB Output is correct
73 Partially correct 65 ms 5240 KB Partially correct - number of queries: 8184
74 Partially correct 77 ms 5240 KB Partially correct - number of queries: 8256
75 Correct 10 ms 5120 KB Output is correct
76 Partially correct 54 ms 5240 KB Partially correct - number of queries: 7141
77 Partially correct 69 ms 5240 KB Partially correct - number of queries: 8160
78 Correct 14 ms 4992 KB Output is correct
79 Correct 38 ms 5112 KB Output is correct
80 Partially correct 68 ms 5240 KB Partially correct - number of queries: 8164
81 Partially correct 73 ms 5200 KB Partially correct - number of queries: 8146
82 Partially correct 63 ms 5240 KB Partially correct - number of queries: 8132
83 Correct 8 ms 4992 KB Output is correct
84 Partially correct 61 ms 5240 KB Partially correct - number of queries: 6779
85 Partially correct 82 ms 5240 KB Partially correct - number of queries: 8214
86 Partially correct 64 ms 5112 KB Partially correct - number of queries: 8525
87 Correct 13 ms 4992 KB Output is correct
88 Partially correct 77 ms 5112 KB Partially correct - number of queries: 8066
89 Partially correct 70 ms 5112 KB Partially correct - number of queries: 8457
90 Correct 9 ms 4992 KB Output is correct
91 Partially correct 52 ms 5112 KB Partially correct - number of queries: 5125
92 Partially correct 68 ms 5112 KB Partially correct - number of queries: 8100
93 Partially correct 73 ms 5112 KB Partially correct - number of queries: 8520
94 Partially correct 63 ms 5284 KB Partially correct - number of queries: 8514
95 Partially correct 74 ms 5112 KB Partially correct - number of queries: 8507
96 Partially correct 70 ms 5112 KB Partially correct - number of queries: 8438
97 Partially correct 76 ms 5112 KB Partially correct - number of queries: 8100