Submission #122595

# Submission time Handle Problem Language Result Execution time Memory
122595 2019-06-28T17:07:19 Z tselmegkh The Big Prize (IOI17_prize) C++14
100 / 100
64 ms 10328 KB
#include<bits/stdc++.h>
#include "prize.h"
using namespace std;

#define INF 1e9
#define MAX 200005
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define ull long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
#define zai <<' '<<
#define all(a) a.begin(),a.end()
#define pc __builtin_popcount
#define debug(args...)  cerr << #args << " = "; Dbg,args; cerr << nl;
struct Dbg { template<typename T> Dbg& operator,(const T& v) { cerr << v << ", "; return *this; } } Dbg;
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){
if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
template<class C> void mini(C &_a, C _b) { _a = min(_a, _b); }
template<class C> void maxi(C &_a, C _b) { _a = max(_a, _b); }

map<int, vi> mymap[MAX];

int res = -1;
void go(int l, int r){
    if(l > r)return;
    if(res != -1)return;
    int mid = (l + r) >> 1;
    vi query = ask(mid);
    if(query[0] + query[1] == 0){
        res = mid;
        return;
    }

    bool ansonl = 1, ansonr = 1;
        auto uit = mymap[query[0] + query[1]].upper_bound(mid);
        if(uit != mymap[query[0] + query[1]].end()){
            if((*uit).second[0] == query[0])ansonr = 0;
        }
        if(uit != mymap[query[0] + query[1]].begin()){
            uit--;
        }
        if(uit != mymap[query[0] + query[1]].begin()){
            if((*uit).second[1] == query[1])ansonl = 0;
        }
    mymap[query[0] + query[1]][mid] = query;
    if(ansonr){
        go(mid + 1, r);
    }
    if(ansonl){
        go(l, mid - 1);
    }
}
int find_best(int n){
    go(0, n - 1);
    return res;
}

# Verdict Execution time Memory Grader output
1 Correct 10 ms 9600 KB Output is correct
2 Correct 10 ms 9600 KB Output is correct
3 Correct 10 ms 9728 KB Output is correct
4 Correct 10 ms 9864 KB Output is correct
5 Correct 9 ms 9728 KB Output is correct
6 Correct 10 ms 9600 KB Output is correct
7 Correct 10 ms 9764 KB Output is correct
8 Correct 10 ms 9776 KB Output is correct
9 Correct 9 ms 9600 KB Output is correct
10 Correct 10 ms 9728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9856 KB Output is correct
2 Correct 10 ms 9648 KB Output is correct
3 Correct 10 ms 9696 KB Output is correct
4 Correct 10 ms 9856 KB Output is correct
5 Correct 11 ms 9728 KB Output is correct
6 Correct 11 ms 9728 KB Output is correct
7 Correct 10 ms 9728 KB Output is correct
8 Correct 10 ms 9600 KB Output is correct
9 Correct 9 ms 9600 KB Output is correct
10 Correct 9 ms 9648 KB Output is correct
11 Correct 11 ms 9720 KB Output is correct
12 Correct 13 ms 9748 KB Output is correct
13 Correct 10 ms 9600 KB Output is correct
14 Correct 19 ms 9772 KB Output is correct
15 Correct 53 ms 10020 KB Output is correct
16 Correct 15 ms 9848 KB Output is correct
17 Correct 63 ms 10252 KB Output is correct
18 Correct 10 ms 9600 KB Output is correct
19 Correct 35 ms 10156 KB Output is correct
20 Correct 20 ms 9848 KB Output is correct
21 Correct 39 ms 10104 KB Output is correct
22 Correct 28 ms 9980 KB Output is correct
23 Correct 11 ms 9792 KB Output is correct
24 Correct 15 ms 9720 KB Output is correct
25 Correct 17 ms 9964 KB Output is correct
26 Correct 17 ms 9936 KB Output is correct
27 Correct 11 ms 9672 KB Output is correct
28 Correct 10 ms 9720 KB Output is correct
29 Correct 11 ms 9788 KB Output is correct
30 Correct 10 ms 9728 KB Output is correct
31 Correct 39 ms 10104 KB Output is correct
32 Correct 10 ms 9720 KB Output is correct
33 Correct 9 ms 9600 KB Output is correct
34 Correct 30 ms 9984 KB Output is correct
35 Correct 10 ms 9600 KB Output is correct
36 Correct 23 ms 10268 KB Output is correct
37 Correct 15 ms 9656 KB Output is correct
38 Correct 11 ms 9788 KB Output is correct
39 Correct 20 ms 10044 KB Output is correct
40 Correct 11 ms 9728 KB Output is correct
41 Correct 31 ms 9848 KB Output is correct
42 Correct 29 ms 9896 KB Output is correct
43 Correct 22 ms 9976 KB Output is correct
44 Correct 29 ms 10148 KB Output is correct
45 Correct 28 ms 10152 KB Output is correct
46 Correct 37 ms 10152 KB Output is correct
47 Correct 25 ms 9848 KB Output is correct
48 Correct 21 ms 9892 KB Output is correct
49 Correct 50 ms 10104 KB Output is correct
50 Correct 10 ms 9600 KB Output is correct
51 Correct 20 ms 10220 KB Output is correct
52 Correct 27 ms 10328 KB Output is correct
53 Correct 12 ms 9748 KB Output is correct
54 Correct 20 ms 10048 KB Output is correct
55 Correct 31 ms 10176 KB Output is correct
56 Correct 10 ms 9628 KB Output is correct
57 Correct 18 ms 9720 KB Output is correct
58 Correct 19 ms 9848 KB Output is correct
59 Correct 22 ms 9848 KB Output is correct
60 Correct 17 ms 9964 KB Output is correct
61 Correct 10 ms 9720 KB Output is correct
62 Correct 12 ms 9724 KB Output is correct
63 Correct 10 ms 9600 KB Output is correct
64 Correct 10 ms 9644 KB Output is correct
65 Correct 11 ms 9728 KB Output is correct
66 Correct 10 ms 9600 KB Output is correct
67 Correct 10 ms 9864 KB Output is correct
68 Correct 10 ms 9600 KB Output is correct
69 Correct 10 ms 9600 KB Output is correct
70 Correct 10 ms 9728 KB Output is correct
71 Correct 43 ms 10272 KB Output is correct
72 Correct 16 ms 9644 KB Output is correct
73 Correct 64 ms 10108 KB Output is correct
74 Correct 49 ms 10180 KB Output is correct
75 Correct 11 ms 9728 KB Output is correct
76 Correct 49 ms 10108 KB Output is correct
77 Correct 37 ms 10232 KB Output is correct
78 Correct 15 ms 9856 KB Output is correct
79 Correct 23 ms 9976 KB Output is correct
80 Correct 40 ms 10104 KB Output is correct
81 Correct 62 ms 10104 KB Output is correct
82 Correct 39 ms 10104 KB Output is correct
83 Correct 10 ms 9728 KB Output is correct
84 Correct 33 ms 10200 KB Output is correct
85 Correct 60 ms 10232 KB Output is correct
86 Correct 20 ms 9984 KB Output is correct
87 Correct 12 ms 9728 KB Output is correct
88 Correct 18 ms 9848 KB Output is correct
89 Correct 20 ms 9720 KB Output is correct
90 Correct 11 ms 9628 KB Output is correct
91 Correct 16 ms 9728 KB Output is correct
92 Correct 10 ms 9600 KB Output is correct
93 Correct 14 ms 9728 KB Output is correct
94 Correct 14 ms 9728 KB Output is correct
95 Correct 13 ms 9728 KB Output is correct
96 Correct 12 ms 9728 KB Output is correct
97 Correct 9 ms 9600 KB Output is correct