Submission #900079

# Submission time Handle Problem Language Result Execution time Memory
900079 2024-01-07T15:12:51 Z sysia The Big Prize (IOI17_prize) C++17
97.57 / 100
27 ms 852 KB
//Sylwia Sapkowska
#include <bits/stdc++.h>
#include "prize.h"
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << "'" << x << "'";}
void __print(const char *x) {cerr << '"' << x << '"';}
void __print(const string &x) {cerr << '"' << x << '"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
typedef pair<int, int> T;
typedef array<int, 2> F;

int find_best(int n) {
	//juz nie trzeba szukac lizakow
	int ans = -1;
	function<void(int, int, F, F)>rec = [&](int l, int r, F L, F R){ 
		//szukamy odp na przedziale [l, r] i wyniki dla elementu pierwszego na lewo od l sa opisane jako para L 
		if (l > r) return;
		int m = (l+r)/2;
		auto x = ask(m);
		F a = {x[0], x[1]};
		if (a[0]+a[1] == 0) {
			ans = m;
			return;
		}
		if (a[0] && a != L) rec(l, m-1, L, a); 
		if (a[1] && a != R) rec(m+1, r, a, R);
		//popatrzmy na przedzial [l, m-1]
		//wiemy ze na lewo od m jest a[m][0] elementow
		//zeby oplacalo sie wywolac, musi byc ich dodatnia ilosc
		//L[0] to ilosc elementow na lewo od l-1
		//oczywiscie zachodzi a[m][0] >= L[0]
		//jesli a[m][0] > L[0], to warto wywolac sie na przedziale [l, m-1], bo moze byc jakis nowy element nienajgorszy na nim
		//jesli a[m][0] = L[0], to znaczy w szczegolnosci, ze te dwa elementy sa tego samego typu
		//(to wynika z faktu, ze ilosc elementow rosnie kwadratowo, i suma mniejszych jest mniejsza niz wartosc ilosci gorszego typu)
		//wiec skoro sa tego samego typu, i pomiedzy nie ma nic lepszego, to nie trzeba sie tam wywolywac
	};
	rec(0, n-1, {-1, -1}, {-1, -1});
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 588 KB Output is correct
4 Correct 1 ms 424 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 428 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 600 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 2 ms 424 KB Output is correct
12 Correct 2 ms 356 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 20 ms 424 KB Output is correct
16 Correct 19 ms 344 KB Output is correct
17 Partially correct 20 ms 600 KB Partially correct - number of queries: 5065
18 Partially correct 26 ms 352 KB Partially correct - number of queries: 5048
19 Correct 20 ms 344 KB Output is correct
20 Correct 14 ms 344 KB Output is correct
21 Correct 25 ms 608 KB Output is correct
22 Correct 21 ms 600 KB Output is correct
23 Correct 1 ms 436 KB Output is correct
24 Correct 2 ms 600 KB Output is correct
25 Correct 24 ms 432 KB Output is correct
26 Correct 24 ms 436 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 23 ms 500 KB Output is correct
29 Correct 18 ms 344 KB Output is correct
30 Correct 24 ms 340 KB Output is correct
31 Correct 20 ms 344 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Partially correct 27 ms 424 KB Partially correct - number of queries: 5020
35 Correct 1 ms 344 KB Output is correct
36 Partially correct 24 ms 344 KB Partially correct - number of queries: 5018
37 Correct 2 ms 344 KB Output is correct
38 Correct 1 ms 432 KB Output is correct
39 Partially correct 25 ms 428 KB Partially correct - number of queries: 5039
40 Correct 18 ms 412 KB Output is correct
41 Partially correct 20 ms 344 KB Partially correct - number of queries: 5058
42 Partially correct 27 ms 432 KB Partially correct - number of queries: 5058
43 Correct 25 ms 344 KB Output is correct
44 Partially correct 19 ms 344 KB Partially correct - number of queries: 5007
45 Correct 21 ms 344 KB Output is correct
46 Partially correct 23 ms 344 KB Partially correct - number of queries: 5035
47 Correct 18 ms 344 KB Output is correct
48 Partially correct 19 ms 596 KB Partially correct - number of queries: 5060
49 Partially correct 22 ms 344 KB Partially correct - number of queries: 5054
50 Partially correct 20 ms 340 KB Partially correct - number of queries: 5007
51 Partially correct 22 ms 344 KB Partially correct - number of queries: 5046
52 Partially correct 20 ms 340 KB Partially correct - number of queries: 5056
53 Correct 1 ms 344 KB Output is correct
54 Correct 17 ms 344 KB Output is correct
55 Partially correct 27 ms 344 KB Partially correct - number of queries: 5054
56 Partially correct 21 ms 344 KB Partially correct - number of queries: 5043
57 Correct 21 ms 340 KB Output is correct
58 Partially correct 23 ms 344 KB Partially correct - number of queries: 5042
59 Partially correct 23 ms 600 KB Partially correct - number of queries: 5047
60 Correct 24 ms 344 KB Output is correct
61 Correct 1 ms 340 KB Output is correct
62 Correct 1 ms 344 KB Output is correct
63 Correct 1 ms 852 KB Output is correct
64 Correct 1 ms 344 KB Output is correct
65 Correct 0 ms 424 KB Output is correct
66 Correct 1 ms 344 KB Output is correct
67 Correct 0 ms 344 KB Output is correct
68 Correct 0 ms 344 KB Output is correct
69 Correct 1 ms 600 KB Output is correct
70 Correct 0 ms 344 KB Output is correct
71 Correct 21 ms 344 KB Output is correct
72 Correct 2 ms 344 KB Output is correct
73 Correct 19 ms 344 KB Output is correct
74 Correct 23 ms 344 KB Output is correct
75 Correct 1 ms 344 KB Output is correct
76 Correct 21 ms 344 KB Output is correct
77 Partially correct 26 ms 344 KB Partially correct - number of queries: 5177
78 Correct 2 ms 344 KB Output is correct
79 Correct 18 ms 516 KB Output is correct
80 Partially correct 26 ms 340 KB Partially correct - number of queries: 5243
81 Partially correct 27 ms 344 KB Partially correct - number of queries: 5221
82 Partially correct 21 ms 344 KB Partially correct - number of queries: 5125
83 Correct 1 ms 432 KB Output is correct
84 Correct 21 ms 600 KB Output is correct
85 Partially correct 24 ms 600 KB Partially correct - number of queries: 5180
86 Correct 2 ms 436 KB Output is correct
87 Correct 1 ms 344 KB Output is correct
88 Correct 2 ms 344 KB Output is correct
89 Correct 2 ms 344 KB Output is correct
90 Correct 1 ms 632 KB Output is correct
91 Correct 2 ms 344 KB Output is correct
92 Correct 0 ms 436 KB Output is correct
93 Correct 2 ms 344 KB Output is correct
94 Correct 2 ms 344 KB Output is correct
95 Correct 3 ms 344 KB Output is correct
96 Correct 1 ms 344 KB Output is correct
97 Correct 0 ms 344 KB Output is correct