Submission #1062399

# Submission time Handle Problem Language Result Execution time Memory
1062399 2024-08-17T06:02:50 Z Sir_Ahmed_Imran The Big Prize (IOI17_prize) C++17
94.41 / 100
37 ms 6152 KB
                                    ///~~~LOTA~~~///
#include <bits/stdc++.h>
#include "prize.h"
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define MAXN 200000
int n;
vector<int> v[MAXN];
vector<int> get(int x){
    if(x>=n || x<0)
        return {0,0};
    if(v[x].empty())
        v[x]=ask(x);
    return v[x];
}
int find_best(int N){
    n=N;
    int m,o,p,q;
    vector<int> a;
    for(int i=m=0;i<n;i+=256){
        a=get(i);
        m=max(m,a[0]+a[1]);
    }
    p=0;q=n-1;
    while(p<n && q>=0){
        a=get(p);
        if(!a[0] && !a[1])
            return p;
        o=(p+256)/256;
        o*=256;
        if(a[0]+a[1]==m  && get(o)==a) 
            p=o;
        else if(a[0]+a[1]==m){
            for(int i=128;i>0;i/=2){
                if(p+i<n && get(p+i)==a)
                    p+=i;
            }
        }
        p++;
        a=get(q);
        if(!a[0] && !a[1])
            return q;
        o=(q-1)/256;
        o*=256;
        if(a[0]+a[1]==m  && get(o)==a) 
            q=o;
        else if(a[0]+a[1]==m){
            for(int i=128;i>0;i/=2){
                if(q>=i && get(q-i)==a)
                    q-=i;
            }
        }
        q--;
    }
    return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5208 KB Output is correct
2 Correct 7 ms 4952 KB Output is correct
3 Correct 7 ms 4952 KB Output is correct
4 Correct 5 ms 4952 KB Output is correct
5 Correct 11 ms 5648 KB Output is correct
6 Correct 5 ms 4952 KB Output is correct
7 Correct 8 ms 4952 KB Output is correct
8 Correct 6 ms 5208 KB Output is correct
9 Correct 9 ms 4952 KB Output is correct
10 Correct 5 ms 5148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5152 KB Output is correct
2 Correct 9 ms 5208 KB Output is correct
3 Correct 8 ms 4952 KB Output is correct
4 Correct 4 ms 4952 KB Output is correct
5 Correct 6 ms 4952 KB Output is correct
6 Correct 4 ms 4952 KB Output is correct
7 Correct 8 ms 5132 KB Output is correct
8 Correct 11 ms 5160 KB Output is correct
9 Correct 6 ms 5164 KB Output is correct
10 Correct 5 ms 5156 KB Output is correct
11 Correct 9 ms 5184 KB Output is correct
12 Correct 3 ms 4948 KB Output is correct
13 Correct 5 ms 4952 KB Output is correct
14 Correct 4 ms 4952 KB Output is correct
15 Correct 15 ms 5436 KB Output is correct
16 Correct 10 ms 5208 KB Output is correct
17 Correct 4 ms 4952 KB Output is correct
18 Correct 7 ms 4952 KB Output is correct
19 Correct 4 ms 4952 KB Output is correct
20 Correct 12 ms 5208 KB Output is correct
21 Correct 18 ms 5240 KB Output is correct
22 Correct 8 ms 4952 KB Output is correct
23 Correct 7 ms 5208 KB Output is correct
24 Correct 5 ms 5128 KB Output is correct
25 Partially correct 24 ms 5168 KB Partially correct - number of queries: 5093
26 Partially correct 25 ms 5200 KB Partially correct - number of queries: 5174
27 Correct 8 ms 4952 KB Output is correct
28 Correct 7 ms 4952 KB Output is correct
29 Correct 11 ms 5168 KB Output is correct
30 Correct 4 ms 5136 KB Output is correct
31 Correct 5 ms 4952 KB Output is correct
32 Correct 8 ms 5140 KB Output is correct
33 Correct 1 ms 4952 KB Output is correct
34 Correct 18 ms 5204 KB Output is correct
35 Correct 6 ms 4952 KB Output is correct
36 Correct 14 ms 5208 KB Output is correct
37 Correct 8 ms 4952 KB Output is correct
38 Correct 6 ms 5464 KB Output is correct
39 Partially correct 37 ms 5208 KB Partially correct - number of queries: 5082
40 Correct 4 ms 5208 KB Output is correct
41 Correct 26 ms 5456 KB Output is correct
42 Correct 28 ms 5208 KB Output is correct
43 Partially correct 18 ms 5188 KB Partially correct - number of queries: 5088
44 Correct 21 ms 5208 KB Output is correct
45 Correct 17 ms 5460 KB Output is correct
46 Correct 4 ms 5208 KB Output is correct
47 Correct 32 ms 5644 KB Output is correct
48 Correct 18 ms 5464 KB Output is correct
49 Correct 8 ms 4952 KB Output is correct
50 Correct 5 ms 4952 KB Output is correct
51 Correct 19 ms 5200 KB Output is correct
52 Correct 8 ms 4952 KB Output is correct
53 Correct 6 ms 5160 KB Output is correct
54 Correct 17 ms 5456 KB Output is correct
55 Correct 6 ms 5152 KB Output is correct
56 Correct 3 ms 4952 KB Output is correct
57 Correct 13 ms 5200 KB Output is correct
58 Correct 17 ms 5460 KB Output is correct
59 Correct 27 ms 5200 KB Output is correct
60 Partially correct 24 ms 5208 KB Partially correct - number of queries: 5332
61 Correct 8 ms 4952 KB Output is correct
62 Correct 7 ms 5208 KB Output is correct
63 Correct 6 ms 4952 KB Output is correct
64 Correct 7 ms 4952 KB Output is correct
65 Correct 5 ms 5208 KB Output is correct
66 Correct 5 ms 4952 KB Output is correct
67 Correct 11 ms 5208 KB Output is correct
68 Correct 7 ms 4952 KB Output is correct
69 Correct 5 ms 4952 KB Output is correct
70 Correct 7 ms 5128 KB Output is correct
71 Partially correct 29 ms 5276 KB Partially correct - number of queries: 5178
72 Correct 4 ms 4952 KB Output is correct
73 Partially correct 19 ms 5224 KB Partially correct - number of queries: 5136
74 Partially correct 32 ms 5208 KB Partially correct - number of queries: 5154
75 Correct 5 ms 4952 KB Output is correct
76 Correct 32 ms 5464 KB Output is correct
77 Partially correct 32 ms 5680 KB Partially correct - number of queries: 5553
78 Correct 6 ms 5220 KB Output is correct
79 Correct 13 ms 5208 KB Output is correct
80 Partially correct 26 ms 6152 KB Partially correct - number of queries: 5559
81 Partially correct 33 ms 5288 KB Partially correct - number of queries: 5524
82 Partially correct 24 ms 5204 KB Partially correct - number of queries: 5533
83 Correct 5 ms 4952 KB Output is correct
84 Correct 26 ms 5396 KB Output is correct
85 Partially correct 24 ms 5200 KB Partially correct - number of queries: 5549
86 Correct 3 ms 4952 KB Output is correct
87 Correct 6 ms 5208 KB Output is correct
88 Correct 5 ms 4952 KB Output is correct
89 Correct 4 ms 4952 KB Output is correct
90 Correct 3 ms 4952 KB Output is correct
91 Correct 3 ms 4952 KB Output is correct
92 Correct 5 ms 4952 KB Output is correct
93 Correct 24 ms 5208 KB Output is correct
94 Correct 32 ms 5456 KB Output is correct
95 Correct 25 ms 5228 KB Output is correct
96 Correct 23 ms 5208 KB Output is correct
97 Correct 6 ms 4952 KB Output is correct