Submission #36550

# Submission time Handle Problem Language Result Execution time Memory
36550 2017-12-10T14:47:08 Z ruhanhabib39 The Big Prize (IOI17_prize) C++14
97.94 / 100
46 ms 6836 KB
#include "prize.h"
#include <bits/stdc++.h>

const int MAXN = 2e5;

std::vector<int> res[MAXN + 10];

std::pair<int,int> get(int i) {
   if(!res[i].size()) res[i] = ask(i);
   return {res[i][0], res[i][1]};
}

int sum(int i) {
   return get(i).first + get(i).second;
}

int ls = 0;

int lowest(int n) {
   int mx = 0;
   for(int i = 0; i*i < n; i++) {
      mx = std::max(mx, sum(i));
   }
   return mx;
}

int solve(int lo, int hi, int lc, int cc) {
   if(!cc || lo > hi) return -1;
   if(lo == hi) {
      if(sum(lo) == 0) return lo;
      else return -1;
   }
   int m = (lo + hi) / 2;
   int ml = m, lf = 0;
   while(ml >= lo && sum(ml) < ls) {
      lf++;
      ml--;
   }
   if(ml >= lo) lf += get(ml).first - lc;
   
   int rr = solve(lo, m, lc, lf);
   if(rr != -1) return rr;

   rr = solve(m+1, hi, lc+lf, cc-lf);
   if(rr != -1) return rr;

   return -1;
}

int find_best(int n) {
   ls = lowest(n); 
   return solve(0, n-1, 0, ls);
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6704 KB Output is correct
2 Correct 0 ms 6704 KB Output is correct
3 Correct 6 ms 6704 KB Output is correct
4 Correct 0 ms 6704 KB Output is correct
5 Correct 0 ms 6704 KB Output is correct
6 Correct 6 ms 6704 KB Output is correct
7 Correct 0 ms 6704 KB Output is correct
8 Correct 3 ms 6704 KB Output is correct
9 Correct 0 ms 6704 KB Output is correct
10 Correct 6 ms 6704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 6704 KB Output is correct
2 Correct 0 ms 6704 KB Output is correct
3 Correct 6 ms 6704 KB Output is correct
4 Correct 3 ms 6704 KB Output is correct
5 Correct 0 ms 6704 KB Output is correct
6 Correct 6 ms 6704 KB Output is correct
7 Correct 3 ms 6704 KB Output is correct
8 Correct 16 ms 6704 KB Output is correct
9 Correct 6 ms 6704 KB Output is correct
10 Correct 0 ms 6704 KB Output is correct
11 Correct 3 ms 6704 KB Output is correct
12 Correct 9 ms 6704 KB Output is correct
13 Correct 0 ms 6704 KB Output is correct
14 Correct 3 ms 6704 KB Output is correct
15 Correct 6 ms 6704 KB Output is correct
16 Correct 36 ms 6836 KB Output is correct
17 Correct 0 ms 6704 KB Output is correct
18 Partially correct 29 ms 6836 KB Partially correct - number of queries: 5055
19 Correct 0 ms 6704 KB Output is correct
20 Correct 0 ms 6704 KB Output is correct
21 Correct 16 ms 6836 KB Output is correct
22 Correct 6 ms 6704 KB Output is correct
23 Correct 0 ms 6704 KB Output is correct
24 Correct 0 ms 6704 KB Output is correct
25 Correct 9 ms 6836 KB Output is correct
26 Correct 9 ms 6836 KB Output is correct
27 Correct 3 ms 6704 KB Output is correct
28 Correct 23 ms 6836 KB Output is correct
29 Correct 23 ms 6836 KB Output is correct
30 Partially correct 46 ms 6836 KB Partially correct - number of queries: 5016
31 Correct 0 ms 6704 KB Output is correct
32 Correct 0 ms 6704 KB Output is correct
33 Correct 0 ms 6704 KB Output is correct
34 Correct 0 ms 6836 KB Output is correct
35 Correct 0 ms 6704 KB Output is correct
36 Correct 3 ms 6704 KB Output is correct
37 Correct 6 ms 6704 KB Output is correct
38 Correct 9 ms 6704 KB Output is correct
39 Correct 13 ms 6836 KB Output is correct
40 Correct 43 ms 6836 KB Output is correct
41 Correct 19 ms 6836 KB Output is correct
42 Correct 9 ms 6836 KB Output is correct
43 Correct 0 ms 6836 KB Output is correct
44 Correct 6 ms 6836 KB Output is correct
45 Correct 6 ms 6836 KB Output is correct
46 Correct 0 ms 6704 KB Output is correct
47 Correct 0 ms 6836 KB Output is correct
48 Correct 19 ms 6836 KB Output is correct
49 Correct 3 ms 6704 KB Output is correct
50 Partially correct 23 ms 6836 KB Partially correct - number of queries: 5049
51 Correct 16 ms 6836 KB Output is correct
52 Correct 9 ms 6704 KB Output is correct
53 Correct 6 ms 6704 KB Output is correct
54 Correct 13 ms 6836 KB Output is correct
55 Correct 3 ms 6704 KB Output is correct
56 Partially correct 33 ms 6836 KB Partially correct - number of queries: 5042
57 Correct 16 ms 6836 KB Output is correct
58 Correct 9 ms 6836 KB Output is correct
59 Correct 13 ms 6836 KB Output is correct
60 Correct 9 ms 6836 KB Output is correct
61 Correct 0 ms 6704 KB Output is correct
62 Correct 6 ms 6704 KB Output is correct
63 Correct 0 ms 6704 KB Output is correct
64 Correct 0 ms 6704 KB Output is correct
65 Correct 6 ms 6704 KB Output is correct
66 Correct 6 ms 6704 KB Output is correct
67 Correct 0 ms 6704 KB Output is correct
68 Correct 0 ms 6704 KB Output is correct
69 Correct 0 ms 6704 KB Output is correct
70 Correct 9 ms 6704 KB Output is correct
71 Partially correct 6 ms 6836 KB Partially correct - number of queries: 5206
72 Correct 3 ms 6704 KB Output is correct
73 Partially correct 26 ms 6836 KB Partially correct - number of queries: 5143
74 Partially correct 19 ms 6836 KB Partially correct - number of queries: 5170
75 Correct 9 ms 6704 KB Output is correct
76 Correct 16 ms 6836 KB Output is correct
77 Partially correct 13 ms 6836 KB Partially correct - number of queries: 5133
78 Correct 9 ms 6704 KB Output is correct
79 Correct 0 ms 6836 KB Output is correct
80 Partially correct 29 ms 6836 KB Partially correct - number of queries: 5138
81 Partially correct 43 ms 6836 KB Partially correct - number of queries: 5129
82 Partially correct 6 ms 6836 KB Partially correct - number of queries: 5081
83 Correct 0 ms 6704 KB Output is correct
84 Correct 39 ms 6836 KB Output is correct
85 Partially correct 43 ms 6836 KB Partially correct - number of queries: 5111
86 Correct 6 ms 6704 KB Output is correct
87 Correct 0 ms 6704 KB Output is correct
88 Correct 3 ms 6704 KB Output is correct
89 Correct 9 ms 6704 KB Output is correct
90 Correct 16 ms 6704 KB Output is correct
91 Correct 3 ms 6704 KB Output is correct
92 Correct 0 ms 6704 KB Output is correct
93 Correct 3 ms 6704 KB Output is correct
94 Correct 3 ms 6704 KB Output is correct
95 Correct 0 ms 6704 KB Output is correct
96 Correct 0 ms 6704 KB Output is correct
97 Correct 6 ms 6704 KB Output is correct