Submission #66284

# Submission time Handle Problem Language Result Execution time Memory
66284 2018-08-10T07:25:19 Z FedericoS The Big Prize (IOI17_prize) C++14
97.42 / 100
115 ms 11580 KB
#include "prize.h"
#include <assert.h>
#include <iostream>
using namespace std;

int N,S,K;
vector<int> A;
vector<int> M[200005];
int calls;
vector<int> vuoto(2,-1);

vector<int> q(int k){

    if(k==-1){
        vector<int> r(2,0);
        r[1]=S;
        return r;
    }

    if(M[k]==vuoto){
        calls++;
        if(calls==10000)
            assert(false);
        M[k]=ask(k);
    }

    //cout<<"q("<<k<<")="<<M[k][0]<<","<<M[k][1]<<endl;
    return M[k];
}

int sinistra(int k){

    int y=k;
    vector<int> V;
    int res=0;
    V=q(k);

    while(V[0]+V[1]!=S){
        res++;
        V=q(--k);
    }

    //cout<<"sinistra("<<y<<")="<<res+V[0]<<endl;
    return res+V[0];

}

int find_best(int n) {

    N=n;
    fill(M,M+N,vuoto);

    for(int i=0;i<min(N,500);i++){
        A=q(i);
        S=max(S,A[0]+A[1]);
    }

    while(K<S){

        int l=0,r=N,m;

        while(l<r){
            m=(l+r)/2;
            if(sinistra(m)<=K)
                l=m+1;
            else
                r=m;
        }

        K++;
        A=q(l);
        if(A[0]==0 and A[1]==0)
            return l;

    }

}

Compilation message

prize.cpp: In function 'int sinistra(int)':
prize.cpp:33:9: warning: unused variable 'y' [-Wunused-variable]
     int y=k;
         ^
prize.cpp: In function 'int find_best(int)':
prize.cpp:77:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 27 ms 11256 KB Output is correct
2 Correct 28 ms 11320 KB Output is correct
3 Correct 27 ms 11320 KB Output is correct
4 Correct 28 ms 11320 KB Output is correct
5 Correct 28 ms 11448 KB Output is correct
6 Correct 28 ms 11448 KB Output is correct
7 Correct 28 ms 11504 KB Output is correct
8 Correct 27 ms 11504 KB Output is correct
9 Correct 28 ms 11504 KB Output is correct
10 Correct 24 ms 11504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 11504 KB Output is correct
2 Correct 32 ms 11504 KB Output is correct
3 Correct 29 ms 11504 KB Output is correct
4 Correct 28 ms 11504 KB Output is correct
5 Correct 30 ms 11504 KB Output is correct
6 Correct 25 ms 11504 KB Output is correct
7 Correct 30 ms 11504 KB Output is correct
8 Correct 22 ms 11504 KB Output is correct
9 Correct 24 ms 11504 KB Output is correct
10 Correct 22 ms 11504 KB Output is correct
11 Correct 33 ms 11520 KB Output is correct
12 Correct 27 ms 11520 KB Output is correct
13 Correct 29 ms 11520 KB Output is correct
14 Correct 14 ms 11520 KB Output is correct
15 Correct 28 ms 11520 KB Output is correct
16 Correct 53 ms 11520 KB Output is correct
17 Correct 27 ms 11520 KB Output is correct
18 Partially correct 86 ms 11520 KB Partially correct - number of queries: 5097
19 Correct 31 ms 11520 KB Output is correct
20 Correct 30 ms 11520 KB Output is correct
21 Correct 40 ms 11520 KB Output is correct
22 Correct 30 ms 11520 KB Output is correct
23 Correct 23 ms 11520 KB Output is correct
24 Correct 25 ms 11520 KB Output is correct
25 Correct 50 ms 11520 KB Output is correct
26 Correct 52 ms 11520 KB Output is correct
27 Correct 32 ms 11520 KB Output is correct
28 Correct 61 ms 11520 KB Output is correct
29 Correct 69 ms 11520 KB Output is correct
30 Partially correct 68 ms 11520 KB Partially correct - number of queries: 5061
31 Correct 31 ms 11520 KB Output is correct
32 Correct 29 ms 11520 KB Output is correct
33 Correct 7 ms 11520 KB Output is correct
34 Correct 40 ms 11520 KB Output is correct
35 Correct 28 ms 11520 KB Output is correct
36 Correct 35 ms 11520 KB Output is correct
37 Correct 33 ms 11520 KB Output is correct
38 Correct 25 ms 11520 KB Output is correct
39 Correct 45 ms 11520 KB Output is correct
40 Correct 46 ms 11520 KB Output is correct
41 Correct 43 ms 11520 KB Output is correct
42 Correct 48 ms 11520 KB Output is correct
43 Correct 41 ms 11520 KB Output is correct
44 Correct 37 ms 11520 KB Output is correct
45 Correct 47 ms 11520 KB Output is correct
46 Correct 24 ms 11520 KB Output is correct
47 Correct 42 ms 11520 KB Output is correct
48 Correct 50 ms 11520 KB Output is correct
49 Correct 27 ms 11520 KB Output is correct
50 Partially correct 63 ms 11520 KB Partially correct - number of queries: 5106
51 Correct 41 ms 11520 KB Output is correct
52 Correct 31 ms 11520 KB Output is correct
53 Correct 25 ms 11520 KB Output is correct
54 Correct 43 ms 11520 KB Output is correct
55 Correct 24 ms 11520 KB Output is correct
56 Partially correct 67 ms 11520 KB Partially correct - number of queries: 5108
57 Correct 59 ms 11520 KB Output is correct
58 Correct 57 ms 11520 KB Output is correct
59 Correct 64 ms 11520 KB Output is correct
60 Correct 61 ms 11520 KB Output is correct
61 Correct 29 ms 11580 KB Output is correct
62 Correct 31 ms 11580 KB Output is correct
63 Correct 35 ms 11580 KB Output is correct
64 Correct 24 ms 11580 KB Output is correct
65 Correct 26 ms 11580 KB Output is correct
66 Correct 84 ms 11580 KB Output is correct
67 Correct 24 ms 11580 KB Output is correct
68 Correct 75 ms 11580 KB Output is correct
69 Correct 78 ms 11580 KB Output is correct
70 Correct 26 ms 11580 KB Output is correct
71 Partially correct 73 ms 11580 KB Partially correct - number of queries: 5258
72 Correct 26 ms 11580 KB Output is correct
73 Partially correct 63 ms 11580 KB Partially correct - number of queries: 5195
74 Partially correct 83 ms 11580 KB Partially correct - number of queries: 5222
75 Correct 25 ms 11580 KB Output is correct
76 Correct 59 ms 11580 KB Output is correct
77 Partially correct 53 ms 11580 KB Partially correct - number of queries: 5184
78 Correct 43 ms 11580 KB Output is correct
79 Correct 43 ms 11580 KB Output is correct
80 Partially correct 53 ms 11580 KB Partially correct - number of queries: 5193
81 Partially correct 82 ms 11580 KB Partially correct - number of queries: 5183
82 Partially correct 65 ms 11580 KB Partially correct - number of queries: 5134
83 Correct 22 ms 11580 KB Output is correct
84 Correct 55 ms 11580 KB Output is correct
85 Partially correct 61 ms 11580 KB Partially correct - number of queries: 5163
86 Correct 76 ms 11580 KB Output is correct
87 Correct 26 ms 11580 KB Output is correct
88 Correct 78 ms 11580 KB Output is correct
89 Correct 88 ms 11580 KB Output is correct
90 Correct 35 ms 11580 KB Output is correct
91 Correct 46 ms 11580 KB Output is correct
92 Correct 83 ms 11580 KB Output is correct
93 Correct 87 ms 11580 KB Output is correct
94 Correct 94 ms 11580 KB Output is correct
95 Correct 115 ms 11580 KB Output is correct
96 Correct 85 ms 11580 KB Output is correct
97 Correct 75 ms 11580 KB Output is correct