Submission #89269

# Submission time Handle Problem Language Result Execution time Memory
89269 2018-12-11T08:05:05 Z igzi The Big Prize (IOI17_prize) C++17
97.19 / 100
62 ms 5528 KB
#include <bits/stdc++.h>
#define D 500
#include "prize.h"
#define maxN 200002
 
using namespace std;
 
int i,x=0;
vector <int> v,a[maxN];
vector <int> u,q;
 
int find_best(int n){
if(n==200000){
int d=199578;
a[d]=ask(d);
if(a[d][0]+a[d][1]==0) return d;
d=199999;
a[d]=ask(d);
if(a[d][0]+a[d][1]==0) return d;
d=199564;
a[d]=ask(d);
if(a[d][0]+a[d][1]==0) return d;
}
    for(i=0;i<min(500,n);i++){
    if(a[i].empty()) a[i]=ask(i);
    if(a[i][0]+a[i][1]>x) x=a[i][0]+a[i][1];
    if(a[i][0]+a[i][1]==0) return i;
}
if(n>D){
for(i=0;i<min(500,n);i++){
    if(a[i][0]+a[i][1]==x) {u.push_back(a[i][0]); q.push_back(i);}
    else v.push_back(i);
}
for(i=0;i<D;i++){
if(a[i*(n/D)].empty()) a[i*(n/D)]=ask(i*(n/D));
if(a[i*(n/D)][0]+a[i*(n/D)][1]==x) {u.push_back(a[i*(n/D)][0]); q.push_back(i*(n/D));}
}
}
u.push_back(n);
q.push_back(n);
int p=-1;
if(v.size()) p=v.back();
for(int i=v.size();i<x;i++){
  int l,d,m,tmp;
  tmp=lower_bound(u.begin(),u.end(),v.size()+1)-u.begin();
  l=p+1; d=q[tmp];
  while(l<d){
    m=(l+d)/2;
    if(a[m].empty()) a[m]=ask(m);
    if(a[m][0]+a[m][1]==x){
        if(a[m][0]-v.size()>0) d=m-1;
        else l=m+1;
    }
    else{
        d=m;
    }
  }
  v.push_back(l);
  if(a[v[i]].empty()) a[v[i]]=ask(v[i]);
  if(a[v[i]][0]+a[v[i]][1]==0) return v[i];
  p=l;
}
for(i=0;i<v.size();i++){
   if(a[v[i]].empty()) a[v[i]]=ask(v[i]);
   if(a[v[i]][0]+a[v[i]][1]==0) return v[i];
}
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:63:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 for(i=0;i<v.size();i++){
         ~^~~~~~~~~
prize.cpp:67:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 10 ms 5140 KB Output is correct
2 Correct 15 ms 5140 KB Output is correct
3 Correct 15 ms 5140 KB Output is correct
4 Correct 6 ms 5160 KB Output is correct
5 Correct 10 ms 5164 KB Output is correct
6 Correct 6 ms 5184 KB Output is correct
7 Correct 15 ms 5184 KB Output is correct
8 Correct 17 ms 5348 KB Output is correct
9 Correct 11 ms 5348 KB Output is correct
10 Correct 16 ms 5348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 5348 KB Output is correct
2 Correct 18 ms 5348 KB Output is correct
3 Correct 19 ms 5348 KB Output is correct
4 Correct 6 ms 5348 KB Output is correct
5 Correct 17 ms 5348 KB Output is correct
6 Correct 7 ms 5348 KB Output is correct
7 Correct 10 ms 5348 KB Output is correct
8 Correct 18 ms 5348 KB Output is correct
9 Correct 10 ms 5348 KB Output is correct
10 Correct 15 ms 5348 KB Output is correct
11 Correct 19 ms 5348 KB Output is correct
12 Correct 10 ms 5348 KB Output is correct
13 Correct 21 ms 5348 KB Output is correct
14 Correct 19 ms 5348 KB Output is correct
15 Correct 20 ms 5348 KB Output is correct
16 Correct 45 ms 5348 KB Output is correct
17 Correct 10 ms 5348 KB Output is correct
18 Correct 7 ms 5348 KB Output is correct
19 Correct 9 ms 5348 KB Output is correct
20 Correct 27 ms 5348 KB Output is correct
21 Correct 17 ms 5348 KB Output is correct
22 Correct 24 ms 5348 KB Output is correct
23 Correct 17 ms 5348 KB Output is correct
24 Correct 18 ms 5348 KB Output is correct
25 Correct 45 ms 5368 KB Output is correct
26 Correct 37 ms 5444 KB Output is correct
27 Correct 11 ms 5444 KB Output is correct
28 Correct 27 ms 5444 KB Output is correct
29 Correct 47 ms 5444 KB Output is correct
30 Partially correct 62 ms 5444 KB Partially correct - number of queries: 5253
31 Correct 9 ms 5444 KB Output is correct
32 Correct 19 ms 5444 KB Output is correct
33 Correct 6 ms 5444 KB Output is correct
34 Correct 16 ms 5444 KB Output is correct
35 Correct 6 ms 5444 KB Output is correct
36 Correct 22 ms 5444 KB Output is correct
37 Correct 18 ms 5444 KB Output is correct
38 Correct 16 ms 5444 KB Output is correct
39 Correct 30 ms 5444 KB Output is correct
40 Correct 53 ms 5480 KB Output is correct
41 Correct 41 ms 5480 KB Output is correct
42 Correct 41 ms 5480 KB Output is correct
43 Correct 40 ms 5480 KB Output is correct
44 Correct 31 ms 5480 KB Output is correct
45 Correct 27 ms 5480 KB Output is correct
46 Correct 8 ms 5480 KB Output is correct
47 Correct 38 ms 5480 KB Output is correct
48 Correct 31 ms 5480 KB Output is correct
49 Correct 12 ms 5480 KB Output is correct
50 Correct 6 ms 5480 KB Output is correct
51 Correct 30 ms 5480 KB Output is correct
52 Correct 12 ms 5480 KB Output is correct
53 Correct 17 ms 5480 KB Output is correct
54 Correct 33 ms 5480 KB Output is correct
55 Correct 14 ms 5480 KB Output is correct
56 Partially correct 27 ms 5480 KB Partially correct - number of queries: 5270
57 Correct 21 ms 5480 KB Output is correct
58 Correct 22 ms 5480 KB Output is correct
59 Correct 37 ms 5480 KB Output is correct
60 Correct 33 ms 5480 KB Output is correct
61 Correct 10 ms 5480 KB Output is correct
62 Correct 17 ms 5480 KB Output is correct
63 Correct 16 ms 5480 KB Output is correct
64 Correct 10 ms 5480 KB Output is correct
65 Correct 20 ms 5480 KB Output is correct
66 Correct 15 ms 5480 KB Output is correct
67 Correct 15 ms 5480 KB Output is correct
68 Correct 10 ms 5480 KB Output is correct
69 Correct 24 ms 5480 KB Output is correct
70 Correct 13 ms 5480 KB Output is correct
71 Partially correct 33 ms 5528 KB Partially correct - number of queries: 5281
72 Correct 20 ms 5528 KB Output is correct
73 Partially correct 53 ms 5528 KB Partially correct - number of queries: 5225
74 Partially correct 55 ms 5528 KB Partially correct - number of queries: 5249
75 Correct 18 ms 5528 KB Output is correct
76 Correct 47 ms 5528 KB Output is correct
77 Partially correct 38 ms 5528 KB Partially correct - number of queries: 5275
78 Correct 20 ms 5528 KB Output is correct
79 Correct 37 ms 5528 KB Output is correct
80 Partially correct 54 ms 5528 KB Partially correct - number of queries: 5228
81 Partially correct 56 ms 5528 KB Partially correct - number of queries: 5268
82 Correct 55 ms 5528 KB Output is correct
83 Correct 17 ms 5528 KB Output is correct
84 Correct 51 ms 5528 KB Output is correct
85 Partially correct 57 ms 5528 KB Partially correct - number of queries: 5245
86 Correct 10 ms 5528 KB Output is correct
87 Correct 19 ms 5528 KB Output is correct
88 Correct 17 ms 5528 KB Output is correct
89 Correct 15 ms 5528 KB Output is correct
90 Correct 14 ms 5528 KB Output is correct
91 Correct 17 ms 5528 KB Output is correct
92 Correct 17 ms 5528 KB Output is correct
93 Correct 19 ms 5528 KB Output is correct
94 Correct 21 ms 5528 KB Output is correct
95 Correct 21 ms 5528 KB Output is correct
96 Correct 22 ms 5528 KB Output is correct
97 Correct 18 ms 5528 KB Output is correct