Submission #1025426

# Submission time Handle Problem Language Result Execution time Memory
1025426 2024-07-17T03:08:05 Z huutuan The Big Prize (IOI17_prize) C++14
90 / 100
152 ms 15300 KB
#include "prize.h"

#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<int> mem[200000];

vector<int> Ask(int i){
   if (mem[i].size()) return mem[i];
   return mem[i]=ask(i);
}

int find_best(int n) {
   for (int i=0; i<n; ++i) mem[i].clear();
   // if (n<=5000){
   //    for (int i=0; i<n; ++i){
   //       auto tmp=ask(i);
   //       if (tmp[0]+tmp[1]==0) return i;
   //    }
   //    return -1;
   // }
   int m=n;
   int mx=0;
   while (m>1){
      m=(int)sqrt(m);
      mx+=m;
   }
   vector<pair<int, int>> v(mx);
   for (int i=0; i<mx; ++i){
      auto tmp=Ask(i);
      v[i]={tmp[0], tmp[1]};
      if (tmp[0]+tmp[1]==0) return i;
   }
   int cnt=0;
   for (auto &i:v) cnt=max(cnt, i.first+i.second);
   ordered_set<int> st, id;
   for (int i=0; i<mx; ++i) if (v[i].first+v[i].second!=cnt) id.insert(i);
   for (int i=mx; i<n; ++i) st.insert(i);
   int rem=cnt-(int)id.size();
   while (rem){
      int l=0, r=(int)st.size()-1;
      while (l<=r){
         int mid=(l+r)>>1;
         int i=*st.find_by_order(mid);
         auto tmp=Ask(i);
         if (tmp[0]+tmp[1]!=cnt){
            id.insert(i);
            st.erase(i);
            --rem;
            break;
         }
         int cntl=tmp[0];
         cntl-=id.order_of_key(i);
         if (cntl) r=mid;
         else l=mid+1;
      }
   }
   for (int i:id){
      auto tmp=Ask(i);
      if (tmp[0]+tmp[1]==0) return i;
   }
   return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 87 ms 14364 KB Output is correct
2 Correct 85 ms 14416 KB Output is correct
3 Correct 84 ms 14312 KB Output is correct
4 Correct 88 ms 14656 KB Output is correct
5 Correct 87 ms 14416 KB Output is correct
6 Correct 2 ms 4952 KB Output is correct
7 Correct 85 ms 14248 KB Output is correct
8 Correct 82 ms 14300 KB Output is correct
9 Correct 79 ms 14416 KB Output is correct
10 Correct 82 ms 14352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 83 ms 14412 KB Output is correct
2 Correct 83 ms 14456 KB Output is correct
3 Correct 85 ms 14416 KB Output is correct
4 Correct 85 ms 14280 KB Output is correct
5 Correct 83 ms 14432 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 82 ms 14320 KB Output is correct
8 Correct 82 ms 14292 KB Output is correct
9 Correct 89 ms 14312 KB Output is correct
10 Correct 92 ms 14320 KB Output is correct
11 Correct 88 ms 14480 KB Output is correct
12 Correct 90 ms 14416 KB Output is correct
13 Correct 90 ms 14424 KB Output is correct
14 Correct 17 ms 6152 KB Output is correct
15 Partially correct 137 ms 14516 KB Partially correct - number of queries: 5682
16 Partially correct 132 ms 14800 KB Partially correct - number of queries: 5935
17 Correct 3 ms 4952 KB Output is correct
18 Partially correct 131 ms 14672 KB Partially correct - number of queries: 6026
19 Correct 4 ms 4952 KB Output is correct
20 Correct 72 ms 10316 KB Output is correct
21 Partially correct 129 ms 14744 KB Partially correct - number of queries: 5866
22 Correct 115 ms 14488 KB Output is correct
23 Correct 87 ms 14344 KB Output is correct
24 Correct 85 ms 14416 KB Output is correct
25 Partially correct 138 ms 15036 KB Partially correct - number of queries: 5789
26 Partially correct 131 ms 14592 KB Partially correct - number of queries: 5720
27 Correct 84 ms 14416 KB Output is correct
28 Partially correct 141 ms 14580 KB Partially correct - number of queries: 5748
29 Correct 126 ms 14688 KB Output is correct
30 Partially correct 132 ms 14696 KB Partially correct - number of queries: 5900
31 Correct 4 ms 4952 KB Output is correct
32 Correct 88 ms 14592 KB Output is correct
33 Correct 1 ms 4952 KB Output is correct
34 Partially correct 134 ms 14600 KB Partially correct - number of queries: 5903
35 Correct 84 ms 14416 KB Output is correct
36 Partially correct 132 ms 14504 KB Partially correct - number of queries: 5933
37 Correct 89 ms 14416 KB Output is correct
38 Correct 86 ms 14416 KB Output is correct
39 Partially correct 135 ms 14756 KB Partially correct - number of queries: 5952
40 Partially correct 123 ms 14672 KB Partially correct - number of queries: 5183
41 Partially correct 128 ms 14672 KB Partially correct - number of queries: 5959
42 Partially correct 134 ms 14852 KB Partially correct - number of queries: 5959
43 Partially correct 131 ms 14928 KB Partially correct - number of queries: 5828
44 Partially correct 132 ms 14644 KB Partially correct - number of queries: 5946
45 Partially correct 142 ms 14672 KB Partially correct - number of queries: 5781
46 Correct 3 ms 4952 KB Output is correct
47 Partially correct 128 ms 14672 KB Partially correct - number of queries: 5823
48 Partially correct 130 ms 14552 KB Partially correct - number of queries: 5922
49 Partially correct 140 ms 15024 KB Partially correct - number of queries: 5975
50 Partially correct 129 ms 14672 KB Partially correct - number of queries: 5987
51 Partially correct 140 ms 14416 KB Partially correct - number of queries: 5964
52 Partially correct 127 ms 14672 KB Partially correct - number of queries: 5989
53 Correct 84 ms 14420 KB Output is correct
54 Partially correct 132 ms 14620 KB Partially correct - number of queries: 5908
55 Correct 3 ms 4952 KB Output is correct
56 Partially correct 134 ms 14756 KB Partially correct - number of queries: 5955
57 Partially correct 127 ms 14612 KB Partially correct - number of queries: 5885
58 Partially correct 133 ms 14632 KB Partially correct - number of queries: 5991
59 Partially correct 139 ms 14420 KB Partially correct - number of queries: 5946
60 Partially correct 136 ms 14448 KB Partially correct - number of queries: 5910
61 Correct 85 ms 14516 KB Output is correct
62 Correct 85 ms 14416 KB Output is correct
63 Correct 86 ms 14416 KB Output is correct
64 Correct 93 ms 14416 KB Output is correct
65 Correct 95 ms 14416 KB Output is correct
66 Correct 122 ms 14732 KB Output is correct
67 Correct 117 ms 14416 KB Output is correct
68 Correct 4 ms 5208 KB Output is correct
69 Correct 113 ms 14416 KB Output is correct
70 Correct 109 ms 14672 KB Output is correct
71 Partially correct 131 ms 15300 KB Partially correct - number of queries: 6624
72 Correct 90 ms 14284 KB Output is correct
73 Partially correct 134 ms 14600 KB Partially correct - number of queries: 6538
74 Partially correct 131 ms 15164 KB Partially correct - number of queries: 6570
75 Correct 84 ms 14416 KB Output is correct
76 Partially correct 124 ms 14540 KB Partially correct - number of queries: 5745
77 Partially correct 128 ms 14592 KB Partially correct - number of queries: 6014
78 Correct 89 ms 14416 KB Output is correct
79 Correct 103 ms 14696 KB Output is correct
80 Partially correct 134 ms 15180 KB Partially correct - number of queries: 6083
81 Partially correct 120 ms 14920 KB Partially correct - number of queries: 6064
82 Partially correct 152 ms 14864 KB Partially correct - number of queries: 5955
83 Correct 84 ms 14412 KB Output is correct
84 Partially correct 125 ms 14620 KB Partially correct - number of queries: 5020
85 Partially correct 143 ms 14672 KB Partially correct - number of queries: 6016
86 Correct 100 ms 14416 KB Output is correct
87 Correct 90 ms 14416 KB Output is correct
88 Correct 87 ms 14416 KB Output is correct
89 Correct 94 ms 14332 KB Output is correct
90 Correct 96 ms 14416 KB Output is correct
91 Correct 105 ms 14416 KB Output is correct
92 Correct 102 ms 14416 KB Output is correct
93 Correct 100 ms 14416 KB Output is correct
94 Correct 102 ms 14416 KB Output is correct
95 Correct 97 ms 14416 KB Output is correct
96 Correct 96 ms 14416 KB Output is correct
97 Correct 92 ms 14416 KB Output is correct