Submission #147494

# Submission time Handle Problem Language Result Execution time Memory
147494 2019-08-29T18:35:55 Z RafaelSus The Big Prize (IOI17_prize) C++17
95.63 / 100
60 ms 504 KB
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;

int mx = -1;
int answ = -1;

int N;

int bSearch(int l, int r, int L, int R){
  l = max(l, 0);
  r = min(r, N);
  if (l >= r) return -1;
  if (L + R == mx) return -1;
  int mid = l + r >> 1;

  for (int i = mid; i < r; i++){
    vector <int> a = ask(i);
    if (a[0] + a[1] == mx){
      int x = bSearch(l, mid, L, a[1] + (mid - i));
      if (x != -1) return x;
      x = bSearch(i + 1, r, a[0], R);
      if (x != -1) return x;
      return -1;
    }else if (a[0] + a[1] == 0){
      return i;
    }
  }
  return bSearch(l, mid, L, R + (r - mid));
}


int find_best(int n){
  N = n;
  for (int i = 0; i < 500; i++){
    vector <int> a = ask(i);
    if (a[0] + a[1] == 0){
      return i;
    }
    mx = max(a[0] + a[1], mx);
  }
  return bSearch(0, n, 0, 0);
}

Compilation message

prize.cpp: In function 'int bSearch(int, int, int, int)':
prize.cpp:16:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = l + r >> 1;
             ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 388 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 4 ms 504 KB Output is correct
4 Correct 7 ms 380 KB Output is correct
5 Correct 7 ms 376 KB Output is correct
6 Correct 2 ms 440 KB Output is correct
7 Correct 4 ms 392 KB Output is correct
8 Correct 9 ms 248 KB Output is correct
9 Correct 7 ms 376 KB Output is correct
10 Correct 8 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 248 KB Output is correct
2 Correct 5 ms 424 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 8 ms 404 KB Output is correct
5 Correct 9 ms 388 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 8 ms 276 KB Output is correct
8 Correct 6 ms 308 KB Output is correct
9 Correct 5 ms 504 KB Output is correct
10 Correct 6 ms 248 KB Output is correct
11 Correct 11 ms 296 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 13 ms 420 KB Output is correct
14 Correct 9 ms 248 KB Output is correct
15 Correct 15 ms 292 KB Output is correct
16 Correct 50 ms 268 KB Output is correct
17 Correct 7 ms 248 KB Output is correct
18 Partially correct 49 ms 276 KB Partially correct - number of queries: 5138
19 Correct 6 ms 308 KB Output is correct
20 Correct 16 ms 248 KB Output is correct
21 Correct 25 ms 244 KB Output is correct
22 Correct 7 ms 316 KB Output is correct
23 Correct 8 ms 248 KB Output is correct
24 Correct 6 ms 280 KB Output is correct
25 Correct 16 ms 312 KB Output is correct
26 Correct 27 ms 248 KB Output is correct
27 Correct 5 ms 248 KB Output is correct
28 Correct 50 ms 248 KB Output is correct
29 Correct 21 ms 388 KB Output is correct
30 Partially correct 53 ms 420 KB Partially correct - number of queries: 5095
31 Correct 4 ms 396 KB Output is correct
32 Correct 6 ms 308 KB Output is correct
33 Correct 2 ms 248 KB Output is correct
34 Correct 23 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 10 ms 396 KB Output is correct
37 Correct 8 ms 248 KB Output is correct
38 Correct 6 ms 248 KB Output is correct
39 Correct 15 ms 504 KB Output is correct
40 Correct 44 ms 248 KB Output is correct
41 Correct 31 ms 248 KB Output is correct
42 Correct 36 ms 248 KB Output is correct
43 Correct 28 ms 376 KB Output is correct
44 Correct 14 ms 316 KB Output is correct
45 Correct 11 ms 392 KB Output is correct
46 Correct 7 ms 248 KB Output is correct
47 Correct 15 ms 308 KB Output is correct
48 Correct 37 ms 304 KB Output is correct
49 Correct 13 ms 392 KB Output is correct
50 Partially correct 29 ms 376 KB Partially correct - number of queries: 5117
51 Correct 14 ms 424 KB Output is correct
52 Correct 7 ms 376 KB Output is correct
53 Correct 5 ms 376 KB Output is correct
54 Correct 24 ms 376 KB Output is correct
55 Correct 6 ms 276 KB Output is correct
56 Partially correct 51 ms 312 KB Partially correct - number of queries: 5117
57 Correct 37 ms 276 KB Output is correct
58 Correct 34 ms 376 KB Output is correct
59 Correct 31 ms 308 KB Output is correct
60 Correct 31 ms 424 KB Output is correct
61 Correct 9 ms 324 KB Output is correct
62 Correct 7 ms 420 KB Output is correct
63 Correct 8 ms 248 KB Output is correct
64 Correct 8 ms 392 KB Output is correct
65 Correct 5 ms 324 KB Output is correct
66 Correct 11 ms 248 KB Output is correct
67 Correct 13 ms 304 KB Output is correct
68 Correct 4 ms 388 KB Output is correct
69 Correct 6 ms 396 KB Output is correct
70 Correct 11 ms 308 KB Output is correct
71 Partially correct 51 ms 296 KB Partially correct - number of queries: 5259
72 Correct 11 ms 248 KB Output is correct
73 Partially correct 60 ms 248 KB Partially correct - number of queries: 5196
74 Partially correct 33 ms 248 KB Partially correct - number of queries: 5223
75 Correct 9 ms 248 KB Output is correct
76 Correct 42 ms 248 KB Output is correct
77 Partially correct 31 ms 308 KB Partially correct - number of queries: 5437
78 Correct 7 ms 376 KB Output is correct
79 Correct 21 ms 376 KB Output is correct
80 Partially correct 32 ms 376 KB Partially correct - number of queries: 5426
81 Partially correct 45 ms 388 KB Partially correct - number of queries: 5414
82 Partially correct 57 ms 376 KB Partially correct - number of queries: 5380
83 Correct 9 ms 248 KB Output is correct
84 Correct 47 ms 248 KB Output is correct
85 Partially correct 58 ms 248 KB Partially correct - number of queries: 5429
86 Correct 10 ms 248 KB Output is correct
87 Correct 5 ms 308 KB Output is correct
88 Correct 12 ms 248 KB Output is correct
89 Correct 14 ms 248 KB Output is correct
90 Correct 9 ms 308 KB Output is correct
91 Correct 9 ms 304 KB Output is correct
92 Correct 13 ms 248 KB Output is correct
93 Correct 14 ms 376 KB Output is correct
94 Correct 16 ms 248 KB Output is correct
95 Correct 17 ms 248 KB Output is correct
96 Correct 17 ms 248 KB Output is correct
97 Correct 14 ms 376 KB Output is correct