Submission #1025431

# Submission time Handle Problem Language Result Execution time Memory
1025431 2024-07-17T03:14:38 Z huutuan The Big Prize (IOI17_prize) C++14
90 / 100
148 ms 15616 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 80 ms 14416 KB Output is correct
2 Correct 69 ms 14344 KB Output is correct
3 Correct 70 ms 14428 KB Output is correct
4 Correct 79 ms 14416 KB Output is correct
5 Correct 82 ms 14332 KB Output is correct
6 Correct 2 ms 4952 KB Output is correct
7 Correct 98 ms 14416 KB Output is correct
8 Correct 84 ms 14424 KB Output is correct
9 Correct 81 ms 14488 KB Output is correct
10 Correct 83 ms 14336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 101 ms 14416 KB Output is correct
2 Correct 96 ms 14300 KB Output is correct
3 Correct 82 ms 14396 KB Output is correct
4 Correct 78 ms 14416 KB Output is correct
5 Correct 80 ms 14368 KB Output is correct
6 Correct 2 ms 4952 KB Output is correct
7 Correct 78 ms 14416 KB Output is correct
8 Correct 98 ms 14416 KB Output is correct
9 Correct 81 ms 14416 KB Output is correct
10 Correct 80 ms 14416 KB Output is correct
11 Correct 88 ms 14756 KB Output is correct
12 Correct 101 ms 14748 KB Output is correct
13 Correct 79 ms 14416 KB Output is correct
14 Correct 14 ms 6136 KB Output is correct
15 Partially correct 120 ms 14844 KB Partially correct - number of queries: 5682
16 Partially correct 139 ms 14672 KB Partially correct - number of queries: 5935
17 Correct 5 ms 4952 KB Output is correct
18 Partially correct 124 ms 14416 KB Partially correct - number of queries: 6026
19 Correct 3 ms 4952 KB Output is correct
20 Correct 54 ms 9808 KB Output is correct
21 Partially correct 116 ms 14852 KB Partially correct - number of queries: 5866
22 Correct 105 ms 14700 KB Output is correct
23 Correct 81 ms 14416 KB Output is correct
24 Correct 81 ms 14504 KB Output is correct
25 Partially correct 124 ms 14572 KB Partially correct - number of queries: 5789
26 Partially correct 128 ms 14928 KB Partially correct - number of queries: 5720
27 Correct 89 ms 14416 KB Output is correct
28 Partially correct 134 ms 14672 KB Partially correct - number of queries: 5748
29 Correct 118 ms 14620 KB Output is correct
30 Partially correct 127 ms 14448 KB Partially correct - number of queries: 5900
31 Correct 4 ms 4952 KB Output is correct
32 Correct 95 ms 14364 KB Output is correct
33 Correct 2 ms 4952 KB Output is correct
34 Partially correct 130 ms 14824 KB Partially correct - number of queries: 5903
35 Correct 86 ms 14308 KB Output is correct
36 Partially correct 123 ms 14928 KB Partially correct - number of queries: 5933
37 Correct 80 ms 14276 KB Output is correct
38 Correct 89 ms 14416 KB Output is correct
39 Partially correct 131 ms 14860 KB Partially correct - number of queries: 5952
40 Partially correct 110 ms 15008 KB Partially correct - number of queries: 5183
41 Partially correct 129 ms 14776 KB Partially correct - number of queries: 5959
42 Partially correct 133 ms 14668 KB Partially correct - number of queries: 5959
43 Partially correct 133 ms 14532 KB Partially correct - number of queries: 5828
44 Partially correct 127 ms 14676 KB Partially correct - number of queries: 5946
45 Partially correct 120 ms 14416 KB Partially correct - number of queries: 5781
46 Correct 4 ms 4952 KB Output is correct
47 Partially correct 126 ms 14416 KB Partially correct - number of queries: 5823
48 Partially correct 119 ms 14824 KB Partially correct - number of queries: 5922
49 Partially correct 126 ms 15616 KB Partially correct - number of queries: 5975
50 Partially correct 137 ms 14796 KB Partially correct - number of queries: 5987
51 Partially correct 123 ms 14908 KB Partially correct - number of queries: 5964
52 Partially correct 123 ms 14672 KB Partially correct - number of queries: 5989
53 Correct 71 ms 14436 KB Output is correct
54 Partially correct 122 ms 15056 KB Partially correct - number of queries: 5908
55 Correct 2 ms 4952 KB Output is correct
56 Partially correct 129 ms 14792 KB Partially correct - number of queries: 5955
57 Partially correct 142 ms 14660 KB Partially correct - number of queries: 5885
58 Partially correct 133 ms 14672 KB Partially correct - number of queries: 5991
59 Partially correct 138 ms 14792 KB Partially correct - number of queries: 5946
60 Partially correct 130 ms 14780 KB Partially correct - number of queries: 5910
61 Correct 82 ms 14416 KB Output is correct
62 Correct 104 ms 14416 KB Output is correct
63 Correct 84 ms 14416 KB Output is correct
64 Correct 90 ms 14336 KB Output is correct
65 Correct 107 ms 14464 KB Output is correct
66 Correct 109 ms 14436 KB Output is correct
67 Correct 110 ms 14536 KB Output is correct
68 Correct 3 ms 4952 KB Output is correct
69 Correct 106 ms 14772 KB Output is correct
70 Correct 100 ms 14568 KB Output is correct
71 Partially correct 121 ms 14828 KB Partially correct - number of queries: 6624
72 Correct 81 ms 14416 KB Output is correct
73 Partially correct 119 ms 15184 KB Partially correct - number of queries: 6538
74 Partially correct 124 ms 14676 KB Partially correct - number of queries: 6570
75 Correct 86 ms 14416 KB Output is correct
76 Partially correct 122 ms 14844 KB Partially correct - number of queries: 5745
77 Partially correct 141 ms 14416 KB Partially correct - number of queries: 6014
78 Correct 82 ms 14412 KB Output is correct
79 Correct 105 ms 14692 KB Output is correct
80 Partially correct 121 ms 14732 KB Partially correct - number of queries: 6083
81 Partially correct 134 ms 14668 KB Partially correct - number of queries: 6064
82 Partially correct 135 ms 14812 KB Partially correct - number of queries: 5955
83 Correct 90 ms 14332 KB Output is correct
84 Partially correct 120 ms 14860 KB Partially correct - number of queries: 5020
85 Partially correct 148 ms 14416 KB Partially correct - number of queries: 6016
86 Correct 101 ms 14416 KB Output is correct
87 Correct 92 ms 14416 KB Output is correct
88 Correct 77 ms 14356 KB Output is correct
89 Correct 97 ms 14332 KB Output is correct
90 Correct 94 ms 14492 KB Output is correct
91 Correct 92 ms 14336 KB Output is correct
92 Correct 95 ms 14344 KB Output is correct
93 Correct 100 ms 14320 KB Output is correct
94 Correct 91 ms 14416 KB Output is correct
95 Correct 104 ms 14416 KB Output is correct
96 Correct 93 ms 14416 KB Output is correct
97 Correct 96 ms 14416 KB Output is correct