//나는 가상 소녀들에게 큰 호감이 있습니다.
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <chrono>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <deque>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdarg.h>
#include <utility>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unisgned long long
#define ld long double
#define all(a) a.begin(), a.end()
#define SORT(a) sort(all(a))
#define pii pair<int, int>
#define tii triple<int, int, int>
#define e 1e-7
#define PI acos(-1)
#define sz(a) (int)(a.size())
#define inf 1e17
#define vi vector<int>
#define F first
#define S second
#define rng(x) for(int _ = 0; _ < (x); _++)
#define rngi(i, x) for(int i = 0; i < (x); i++)
#define rngsi(s, i, x) for(int i = (s); i <(x); i++)
#define problem "a"
template<typename A, typename B, typename C>
struct triple {
A X;
B Y;
C Z;
triple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}
};
template<typename A, typename B, typename C>
triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0) {
return triple<A, B, C>(a, b, c);
}
template<typename A, typename B, typename C>
bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b) {
if (a.X != b.X)
return a.X < b.X;
if (a.Y != b.Y)
return a.Y < b.Y;
return a.Z < b.Z;
}
template<typename T, typename SS>
ostream& operator<<(ostream& ofs, const pair<T, SS>& p) {
ofs << "( " << p.F << " , " << p.S << " )";
return ofs;
}
template<typename T>
void print(T a) {
for (auto i : a)
cout << i << ' ';
cout << '\n';
}
template<typename T>
T max(T a, T b, T c) {
return max(a, max(b, c));
}
template<typename T>
T min(T a, T b, T c) {
return min(a, min(b, c));
}
template<typename T, typename D>
D min(T a) {
return *min_element(all(a));
}
template<typename T, typename D>
D max(T a) {
return *max_element(all(a));
}
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
#include "prize.h"
vector<vi> aans;
vi aask(int v) {
if (!sz(aans[v]))aans[v] = ask(v);
return aans[v];
}
int find_best(int n) {
aans.resize(n);
int mx = 0;
rngi(i, min(n, 472)) {
auto v = aask(i);
if (v[0] + v[1] == 0) return i;
mx = max(mx, v[0] + v[1]);
}
for (int i = 472; i < n;) {
auto v = aask(i);
if (v[0] + v[1] == 0)return i;
if (v[0] + v[1] == mx) {
int l = i + 1, r = n - 1;
while (l < r) {
int m = l + r >> 1;
auto t = aask(m);
if (t[0] + t[1] == 0)return m;
if (t[0] + t[1] < mx)r = m;
else {
if (v[1] - t[1] > 0) r = m - 1;
else l = m + 1;
}
}
v = aask(l);
if (v[0] + v[1] == 0)return l;
i = l;
}
i++;
}
return 0;
}
Compilation message
prize.cpp: In function 'int find_best(int)':
prize.cpp:132:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
132 | int m = l + r >> 1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4988 KB |
Output is correct |
2 |
Correct |
7 ms |
4992 KB |
Output is correct |
3 |
Correct |
8 ms |
4992 KB |
Output is correct |
4 |
Correct |
11 ms |
4992 KB |
Output is correct |
5 |
Correct |
13 ms |
4992 KB |
Output is correct |
6 |
Correct |
4 ms |
4992 KB |
Output is correct |
7 |
Correct |
9 ms |
4968 KB |
Output is correct |
8 |
Correct |
8 ms |
4992 KB |
Output is correct |
9 |
Correct |
8 ms |
4992 KB |
Output is correct |
10 |
Correct |
9 ms |
4992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
4984 KB |
Output is correct |
2 |
Correct |
11 ms |
4992 KB |
Output is correct |
3 |
Correct |
9 ms |
4984 KB |
Output is correct |
4 |
Correct |
8 ms |
4984 KB |
Output is correct |
5 |
Correct |
10 ms |
4984 KB |
Output is correct |
6 |
Correct |
4 ms |
4992 KB |
Output is correct |
7 |
Correct |
9 ms |
5120 KB |
Output is correct |
8 |
Correct |
8 ms |
4992 KB |
Output is correct |
9 |
Correct |
8 ms |
4992 KB |
Output is correct |
10 |
Correct |
8 ms |
4992 KB |
Output is correct |
11 |
Correct |
14 ms |
4992 KB |
Output is correct |
12 |
Correct |
9 ms |
4992 KB |
Output is correct |
13 |
Correct |
12 ms |
4984 KB |
Output is correct |
14 |
Correct |
9 ms |
896 KB |
Output is correct |
15 |
Correct |
25 ms |
5112 KB |
Output is correct |
16 |
Partially correct |
58 ms |
5372 KB |
Partially correct - number of queries: 7118 |
17 |
Correct |
8 ms |
4992 KB |
Output is correct |
18 |
Partially correct |
82 ms |
5240 KB |
Partially correct - number of queries: 8250 |
19 |
Correct |
9 ms |
4984 KB |
Output is correct |
20 |
Correct |
26 ms |
2816 KB |
Output is correct |
21 |
Correct |
50 ms |
5112 KB |
Output is correct |
22 |
Correct |
12 ms |
4984 KB |
Output is correct |
23 |
Correct |
9 ms |
4992 KB |
Output is correct |
24 |
Correct |
9 ms |
4992 KB |
Output is correct |
25 |
Correct |
44 ms |
5112 KB |
Output is correct |
26 |
Correct |
46 ms |
5112 KB |
Output is correct |
27 |
Correct |
8 ms |
4992 KB |
Output is correct |
28 |
Partially correct |
55 ms |
5396 KB |
Partially correct - number of queries: 7798 |
29 |
Partially correct |
55 ms |
5240 KB |
Partially correct - number of queries: 6022 |
30 |
Partially correct |
99 ms |
5496 KB |
Partially correct - number of queries: 8195 |
31 |
Correct |
7 ms |
4984 KB |
Output is correct |
32 |
Correct |
12 ms |
4992 KB |
Output is correct |
33 |
Correct |
1 ms |
256 KB |
Output is correct |
34 |
Correct |
23 ms |
5296 KB |
Output is correct |
35 |
Correct |
15 ms |
5120 KB |
Output is correct |
36 |
Correct |
26 ms |
5116 KB |
Output is correct |
37 |
Correct |
9 ms |
4992 KB |
Output is correct |
38 |
Correct |
12 ms |
4992 KB |
Output is correct |
39 |
Correct |
41 ms |
5112 KB |
Output is correct |
40 |
Partially correct |
59 ms |
5372 KB |
Partially correct - number of queries: 7101 |
41 |
Partially correct |
54 ms |
5112 KB |
Partially correct - number of queries: 5129 |
42 |
Partially correct |
54 ms |
5240 KB |
Partially correct - number of queries: 5129 |
43 |
Correct |
57 ms |
5220 KB |
Output is correct |
44 |
Correct |
53 ms |
5112 KB |
Output is correct |
45 |
Correct |
42 ms |
5112 KB |
Output is correct |
46 |
Correct |
9 ms |
4992 KB |
Output is correct |
47 |
Correct |
45 ms |
5112 KB |
Output is correct |
48 |
Partially correct |
80 ms |
5240 KB |
Partially correct - number of queries: 6233 |
49 |
Correct |
18 ms |
4992 KB |
Output is correct |
50 |
Partially correct |
87 ms |
5324 KB |
Partially correct - number of queries: 8247 |
51 |
Correct |
38 ms |
5112 KB |
Output is correct |
52 |
Correct |
11 ms |
4984 KB |
Output is correct |
53 |
Correct |
12 ms |
5224 KB |
Output is correct |
54 |
Correct |
48 ms |
5112 KB |
Output is correct |
55 |
Correct |
12 ms |
4992 KB |
Output is correct |
56 |
Partially correct |
76 ms |
5240 KB |
Partially correct - number of queries: 8244 |
57 |
Partially correct |
57 ms |
5240 KB |
Partially correct - number of queries: 6150 |
58 |
Partially correct |
55 ms |
5240 KB |
Partially correct - number of queries: 6221 |
59 |
Partially correct |
52 ms |
5240 KB |
Partially correct - number of queries: 5123 |
60 |
Correct |
64 ms |
5240 KB |
Output is correct |
61 |
Correct |
9 ms |
4992 KB |
Output is correct |
62 |
Correct |
9 ms |
4992 KB |
Output is correct |
63 |
Correct |
9 ms |
4984 KB |
Output is correct |
64 |
Correct |
10 ms |
4992 KB |
Output is correct |
65 |
Correct |
10 ms |
4992 KB |
Output is correct |
66 |
Correct |
13 ms |
4992 KB |
Output is correct |
67 |
Correct |
10 ms |
4992 KB |
Output is correct |
68 |
Correct |
9 ms |
4984 KB |
Output is correct |
69 |
Correct |
13 ms |
4984 KB |
Output is correct |
70 |
Correct |
11 ms |
4992 KB |
Output is correct |
71 |
Partially correct |
85 ms |
5240 KB |
Partially correct - number of queries: 8226 |
72 |
Correct |
16 ms |
4992 KB |
Output is correct |
73 |
Partially correct |
76 ms |
5240 KB |
Partially correct - number of queries: 8136 |
74 |
Partially correct |
85 ms |
5240 KB |
Partially correct - number of queries: 8175 |
75 |
Correct |
10 ms |
4992 KB |
Output is correct |
76 |
Partially correct |
71 ms |
5264 KB |
Partially correct - number of queries: 7104 |
77 |
Partially correct |
104 ms |
5240 KB |
Partially correct - number of queries: 8301 |
78 |
Correct |
14 ms |
5120 KB |
Output is correct |
79 |
Correct |
27 ms |
5084 KB |
Output is correct |
80 |
Partially correct |
81 ms |
5372 KB |
Partially correct - number of queries: 8285 |
81 |
Partially correct |
96 ms |
5368 KB |
Partially correct - number of queries: 8309 |
82 |
Partially correct |
69 ms |
5240 KB |
Partially correct - number of queries: 8184 |
83 |
Correct |
8 ms |
4992 KB |
Output is correct |
84 |
Partially correct |
70 ms |
5200 KB |
Partially correct - number of queries: 6836 |
85 |
Partially correct |
74 ms |
5372 KB |
Partially correct - number of queries: 8263 |
86 |
Correct |
10 ms |
4992 KB |
Output is correct |
87 |
Correct |
11 ms |
5120 KB |
Output is correct |
88 |
Correct |
10 ms |
4992 KB |
Output is correct |
89 |
Correct |
7 ms |
4992 KB |
Output is correct |
90 |
Correct |
11 ms |
4992 KB |
Output is correct |
91 |
Correct |
8 ms |
4992 KB |
Output is correct |
92 |
Correct |
8 ms |
4992 KB |
Output is correct |
93 |
Correct |
10 ms |
4992 KB |
Output is correct |
94 |
Correct |
14 ms |
5120 KB |
Output is correct |
95 |
Correct |
15 ms |
4992 KB |
Output is correct |
96 |
Correct |
11 ms |
4992 KB |
Output is correct |
97 |
Correct |
10 ms |
4992 KB |
Output is correct |