답안 #977395

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
977395 2024-05-07T21:05:17 Z mariaclara 커다란 상품 (IOI17_prize) C++17
90 / 100
61 ms 2136 KB
#include "prize.h"
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second

int lolipop;
vector<pii> resp;

int a(int x) {
	if(resp[x].fr != -1) return resp[x].fr;
	vector<int> aux = ask(x);
	resp[x] = {aux[0], aux[1]};
	return resp[x].fr;
}

int b(int x) {
	if(resp[x].sc != -1) return resp[x].sc;
	vector<int> aux = ask(x);
	resp[x] = {aux[0], aux[1]};
	return resp[x].sc;
}

int query(int l, int r) {
	while(l <= r and a(l) + b(l) != lolipop) {
		if(a(l) + b(l) == 0) return l;
		l++;
	}

	while(l <= r and a(r) + b(r) != lolipop) {
		if(a(r) + b(r) == 0) return r;
		r--;
	}

	if(l > r or a(l) == a(r)) return -1; // checo se o intervalo é valido e se existe um valor diferente de lolipop nele

	int mid = (l+r)/2;
	return max(query(l,mid), query(mid+1,r));
}
int find_best(int n) {
	resp.resize(n, mk(-1,-1));

	for(int i = 0; i < min(500,n); i++) lolipop = max(lolipop, a(i) + b(i));

	return query(0, n-1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1880 KB Output is correct
2 Correct 3 ms 1880 KB Output is correct
3 Correct 3 ms 2136 KB Output is correct
4 Correct 3 ms 1880 KB Output is correct
5 Correct 3 ms 1880 KB Output is correct
6 Correct 3 ms 1880 KB Output is correct
7 Correct 4 ms 1880 KB Output is correct
8 Correct 3 ms 1960 KB Output is correct
9 Correct 3 ms 1880 KB Output is correct
10 Correct 3 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1880 KB Output is correct
2 Correct 3 ms 1880 KB Output is correct
3 Correct 3 ms 1880 KB Output is correct
4 Correct 3 ms 1876 KB Output is correct
5 Correct 3 ms 1880 KB Output is correct
6 Correct 4 ms 1876 KB Output is correct
7 Correct 3 ms 1880 KB Output is correct
8 Correct 3 ms 1880 KB Output is correct
9 Correct 3 ms 1880 KB Output is correct
10 Correct 3 ms 1880 KB Output is correct
11 Correct 7 ms 1880 KB Output is correct
12 Correct 5 ms 1880 KB Output is correct
13 Correct 7 ms 1880 KB Output is correct
14 Correct 12 ms 600 KB Output is correct
15 Partially correct 32 ms 1880 KB Partially correct - number of queries: 7542
16 Partially correct 44 ms 1880 KB Partially correct - number of queries: 7957
17 Partially correct 39 ms 1880 KB Partially correct - number of queries: 7953
18 Partially correct 51 ms 1880 KB Partially correct - number of queries: 8005
19 Partially correct 40 ms 1880 KB Partially correct - number of queries: 7611
20 Partially correct 23 ms 1360 KB Partially correct - number of queries: 5302
21 Partially correct 42 ms 1880 KB Partially correct - number of queries: 7934
22 Partially correct 29 ms 1876 KB Partially correct - number of queries: 6280
23 Correct 4 ms 1880 KB Output is correct
24 Correct 6 ms 1880 KB Output is correct
25 Partially correct 30 ms 1880 KB Partially correct - number of queries: 7251
26 Partially correct 41 ms 1880 KB Partially correct - number of queries: 7161
27 Correct 4 ms 2040 KB Output is correct
28 Partially correct 39 ms 1880 KB Partially correct - number of queries: 7224
29 Partially correct 35 ms 1880 KB Partially correct - number of queries: 6170
30 Partially correct 41 ms 1880 KB Partially correct - number of queries: 7959
31 Partially correct 61 ms 1880 KB Partially correct - number of queries: 7882
32 Correct 8 ms 1880 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Partially correct 44 ms 1880 KB Partially correct - number of queries: 7994
35 Correct 5 ms 1880 KB Output is correct
36 Partially correct 39 ms 1880 KB Partially correct - number of queries: 8037
37 Correct 5 ms 1880 KB Output is correct
38 Correct 4 ms 2132 KB Output is correct
39 Partially correct 37 ms 1880 KB Partially correct - number of queries: 7961
40 Partially correct 30 ms 1880 KB Partially correct - number of queries: 7002
41 Partially correct 40 ms 1880 KB Partially correct - number of queries: 7979
42 Partially correct 38 ms 1880 KB Partially correct - number of queries: 7979
43 Partially correct 39 ms 1880 KB Partially correct - number of queries: 7783
44 Partially correct 37 ms 2136 KB Partially correct - number of queries: 7955
45 Partially correct 38 ms 2036 KB Partially correct - number of queries: 7175
46 Partially correct 42 ms 1880 KB Partially correct - number of queries: 7998
47 Partially correct 27 ms 1880 KB Partially correct - number of queries: 7291
48 Partially correct 40 ms 1880 KB Partially correct - number of queries: 7961
49 Partially correct 44 ms 1880 KB Partially correct - number of queries: 8032
50 Partially correct 45 ms 1880 KB Partially correct - number of queries: 7965
51 Partially correct 38 ms 1880 KB Partially correct - number of queries: 7974
52 Partially correct 45 ms 1876 KB Partially correct - number of queries: 8030
53 Correct 4 ms 1880 KB Output is correct
54 Partially correct 38 ms 1880 KB Partially correct - number of queries: 7946
55 Partially correct 38 ms 1880 KB Partially correct - number of queries: 8008
56 Partially correct 46 ms 1876 KB Partially correct - number of queries: 8050
57 Partially correct 47 ms 1880 KB Partially correct - number of queries: 7987
58 Partially correct 45 ms 1880 KB Partially correct - number of queries: 7991
59 Partially correct 47 ms 1880 KB Partially correct - number of queries: 8021
60 Partially correct 46 ms 1880 KB Partially correct - number of queries: 7967
61 Correct 4 ms 1880 KB Output is correct
62 Correct 4 ms 1880 KB Output is correct
63 Correct 4 ms 1880 KB Output is correct
64 Correct 4 ms 1880 KB Output is correct
65 Correct 3 ms 1880 KB Output is correct
66 Correct 4 ms 1880 KB Output is correct
67 Correct 5 ms 1876 KB Output is correct
68 Correct 3 ms 1880 KB Output is correct
69 Correct 3 ms 1880 KB Output is correct
70 Correct 4 ms 1880 KB Output is correct
71 Partially correct 47 ms 1880 KB Partially correct - number of queries: 9073
72 Correct 8 ms 1880 KB Output is correct
73 Partially correct 44 ms 1880 KB Partially correct - number of queries: 8961
74 Partially correct 46 ms 1880 KB Partially correct - number of queries: 9009
75 Correct 4 ms 1880 KB Output is correct
76 Partially correct 40 ms 1876 KB Partially correct - number of queries: 7921
77 Partially correct 36 ms 1880 KB Partially correct - number of queries: 7870
78 Correct 6 ms 1880 KB Output is correct
79 Correct 25 ms 1876 KB Output is correct
80 Partially correct 46 ms 1880 KB Partially correct - number of queries: 8003
81 Partially correct 34 ms 1880 KB Partially correct - number of queries: 7952
82 Partially correct 44 ms 1880 KB Partially correct - number of queries: 7781
83 Correct 4 ms 1880 KB Output is correct
84 Partially correct 33 ms 1880 KB Partially correct - number of queries: 6670
85 Partially correct 45 ms 1880 KB Partially correct - number of queries: 7973
86 Correct 3 ms 1880 KB Output is correct
87 Correct 3 ms 1880 KB Output is correct
88 Correct 3 ms 1880 KB Output is correct
89 Correct 4 ms 1880 KB Output is correct
90 Correct 3 ms 1880 KB Output is correct
91 Correct 3 ms 1880 KB Output is correct
92 Correct 3 ms 1880 KB Output is correct
93 Correct 5 ms 1880 KB Output is correct
94 Correct 5 ms 1880 KB Output is correct
95 Correct 5 ms 1880 KB Output is correct
96 Correct 5 ms 1880 KB Output is correct
97 Correct 4 ms 2132 KB Output is correct