#include "bits/stdc++.h"
#include "prize.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x) cerr<< #x <<" = "<< x<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
//~ vector<int>arr;
//~ int cnt=0;
//~ vector<int>ask(int x){
//~ int a=0,b=0;
//~ for(int i=0;i<x;i++)
//~ a+=(arr[x]>arr[i]);
//~ for(int i=x+1;i<(int)arr.size();i++)
//~ b+=(arr[x]>arr[i]);
//~ vector<int>v;v.pb(a);v.pb(b);
//~ cnt++;
//~ return v;
//~ }
const int C=5;
int find_best(int n){
int mx=0;
for(int i=0;i<n;i++){
vector<int>res=ask(i);
if(res[0]+res[1]==0)
return i;
umax(mx,res[0]+res[1]);
if(res[0]+res[1]<mx)
continue;
if(i+C<n and ask(i+C)==res){
int st=i+1,en=n-1;
while(st<=en){
int mid=(st+en)>>1;
if(ask(mid)==res){
i=mid;
st=mid+1;
}
else
en=mid-1;
}
}
else{
for(int j=i+1;j<n;j++)
if(res!=ask(j)){
j=i-1;
break;
}
}
}
return -1;
}
//~ int main(){
//~ freopen("file.in", "r", stdin);
//~ int n;
//~ scanf("%d",&n);
//~ for(int i=0;i<n;i++){
//~ int x;
//~ scanf("%d",&x);
//~ arr.pb(x);
//~ }
//~ for(int i=0;i<n;i++)
//~ if(arr[i]==1){
//~ if(find_best(n)==i)
//~ puts("ok");
//~ else
//~ puts("wa");
//~ debug(cnt);
//~ return 0;
//~ }
//~ return 0;
//~ }
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
436 KB |
Output is correct |
3 |
Correct |
2 ms |
516 KB |
Output is correct |
4 |
Correct |
2 ms |
516 KB |
Output is correct |
5 |
Correct |
2 ms |
516 KB |
Output is correct |
6 |
Correct |
2 ms |
516 KB |
Output is correct |
7 |
Correct |
2 ms |
516 KB |
Output is correct |
8 |
Correct |
2 ms |
516 KB |
Output is correct |
9 |
Correct |
2 ms |
532 KB |
Output is correct |
10 |
Correct |
2 ms |
532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
532 KB |
Output is correct |
2 |
Correct |
2 ms |
532 KB |
Output is correct |
3 |
Correct |
3 ms |
548 KB |
Output is correct |
4 |
Correct |
2 ms |
548 KB |
Output is correct |
5 |
Correct |
2 ms |
548 KB |
Output is correct |
6 |
Correct |
2 ms |
548 KB |
Output is correct |
7 |
Correct |
2 ms |
548 KB |
Output is correct |
8 |
Correct |
2 ms |
548 KB |
Output is correct |
9 |
Correct |
2 ms |
560 KB |
Output is correct |
10 |
Correct |
2 ms |
560 KB |
Output is correct |
11 |
Correct |
4 ms |
560 KB |
Output is correct |
12 |
Correct |
2 ms |
560 KB |
Output is correct |
13 |
Correct |
7 ms |
560 KB |
Output is correct |
14 |
Correct |
4 ms |
560 KB |
Output is correct |
15 |
Correct |
8 ms |
560 KB |
Output is correct |
16 |
Partially correct |
56 ms |
560 KB |
Partially correct - number of queries: 7724 |
17 |
Correct |
2 ms |
560 KB |
Output is correct |
18 |
Partially correct |
46 ms |
560 KB |
Partially correct - number of queries: 9081 |
19 |
Correct |
2 ms |
560 KB |
Output is correct |
20 |
Correct |
21 ms |
560 KB |
Output is correct |
21 |
Correct |
31 ms |
560 KB |
Output is correct |
22 |
Correct |
7 ms |
560 KB |
Output is correct |
23 |
Correct |
2 ms |
560 KB |
Output is correct |
24 |
Correct |
2 ms |
560 KB |
Output is correct |
25 |
Partially correct |
25 ms |
560 KB |
Partially correct - number of queries: 5120 |
26 |
Partially correct |
44 ms |
560 KB |
Partially correct - number of queries: 5007 |
27 |
Correct |
2 ms |
560 KB |
Output is correct |
28 |
Partially correct |
68 ms |
560 KB |
Partially correct - number of queries: 8594 |
29 |
Partially correct |
51 ms |
572 KB |
Partially correct - number of queries: 6516 |
30 |
Partially correct |
37 ms |
572 KB |
Partially correct - number of queries: 9020 |
31 |
Correct |
2 ms |
572 KB |
Output is correct |
32 |
Correct |
5 ms |
572 KB |
Output is correct |
33 |
Correct |
2 ms |
572 KB |
Output is correct |
34 |
Correct |
31 ms |
572 KB |
Output is correct |
35 |
Correct |
3 ms |
572 KB |
Output is correct |
36 |
Correct |
23 ms |
572 KB |
Output is correct |
37 |
Correct |
3 ms |
572 KB |
Output is correct |
38 |
Correct |
2 ms |
572 KB |
Output is correct |
39 |
Correct |
37 ms |
572 KB |
Output is correct |
40 |
Partially correct |
66 ms |
572 KB |
Partially correct - number of queries: 7706 |
41 |
Partially correct |
35 ms |
572 KB |
Partially correct - number of queries: 5418 |
42 |
Partially correct |
41 ms |
572 KB |
Partially correct - number of queries: 5418 |
43 |
Correct |
26 ms |
572 KB |
Output is correct |
44 |
Correct |
29 ms |
572 KB |
Output is correct |
45 |
Correct |
30 ms |
572 KB |
Output is correct |
46 |
Correct |
2 ms |
572 KB |
Output is correct |
47 |
Correct |
44 ms |
572 KB |
Output is correct |
48 |
Partially correct |
51 ms |
572 KB |
Partially correct - number of queries: 6701 |
49 |
Correct |
7 ms |
572 KB |
Output is correct |
50 |
Partially correct |
36 ms |
572 KB |
Partially correct - number of queries: 9078 |
51 |
Correct |
26 ms |
572 KB |
Output is correct |
52 |
Correct |
2 ms |
572 KB |
Output is correct |
53 |
Correct |
2 ms |
572 KB |
Output is correct |
54 |
Correct |
30 ms |
572 KB |
Output is correct |
55 |
Correct |
2 ms |
572 KB |
Output is correct |
56 |
Partially correct |
96 ms |
572 KB |
Partially correct - number of queries: 9080 |
57 |
Partially correct |
48 ms |
572 KB |
Partially correct - number of queries: 6619 |
58 |
Partially correct |
51 ms |
572 KB |
Partially correct - number of queries: 6732 |
59 |
Partially correct |
42 ms |
572 KB |
Partially correct - number of queries: 5418 |
60 |
Partially correct |
50 ms |
572 KB |
Partially correct - number of queries: 5029 |
61 |
Correct |
3 ms |
572 KB |
Output is correct |
62 |
Correct |
2 ms |
572 KB |
Output is correct |
63 |
Correct |
3 ms |
572 KB |
Output is correct |
64 |
Correct |
2 ms |
572 KB |
Output is correct |
65 |
Correct |
2 ms |
572 KB |
Output is correct |
66 |
Correct |
4 ms |
572 KB |
Output is correct |
67 |
Correct |
3 ms |
572 KB |
Output is correct |
68 |
Correct |
2 ms |
572 KB |
Output is correct |
69 |
Correct |
4 ms |
572 KB |
Output is correct |
70 |
Correct |
2 ms |
572 KB |
Output is correct |
71 |
Partially correct |
68 ms |
572 KB |
Partially correct - number of queries: 9205 |
72 |
Correct |
7 ms |
572 KB |
Output is correct |
73 |
Partially correct |
76 ms |
572 KB |
Partially correct - number of queries: 9084 |
74 |
Partially correct |
70 ms |
572 KB |
Partially correct - number of queries: 9130 |
75 |
Correct |
3 ms |
572 KB |
Output is correct |
76 |
Partially correct |
52 ms |
572 KB |
Partially correct - number of queries: 7859 |
77 |
Partially correct |
74 ms |
572 KB |
Partially correct - number of queries: 9078 |
78 |
Correct |
28 ms |
572 KB |
Output is correct |
79 |
Correct |
26 ms |
572 KB |
Output is correct |
80 |
Partially correct |
70 ms |
572 KB |
Partially correct - number of queries: 9099 |
81 |
Partially correct |
49 ms |
572 KB |
Partially correct - number of queries: 9077 |
82 |
Partially correct |
84 ms |
572 KB |
Partially correct - number of queries: 9015 |
83 |
Correct |
3 ms |
572 KB |
Output is correct |
84 |
Partially correct |
49 ms |
572 KB |
Partially correct - number of queries: 7427 |
85 |
Partially correct |
65 ms |
572 KB |
Partially correct - number of queries: 9085 |
86 |
Partially correct |
85 ms |
572 KB |
Partially correct - number of queries: 8615 |
87 |
Correct |
5 ms |
572 KB |
Output is correct |
88 |
Partially correct |
66 ms |
572 KB |
Partially correct - number of queries: 8124 |
89 |
Partially correct |
64 ms |
572 KB |
Partially correct - number of queries: 8535 |
90 |
Correct |
2 ms |
572 KB |
Output is correct |
91 |
Correct |
32 ms |
572 KB |
Output is correct |
92 |
Correct |
2 ms |
572 KB |
Output is correct |
93 |
Correct |
6 ms |
572 KB |
Output is correct |
94 |
Correct |
4 ms |
572 KB |
Output is correct |
95 |
Correct |
5 ms |
572 KB |
Output is correct |
96 |
Correct |
4 ms |
572 KB |
Output is correct |
97 |
Correct |
2 ms |
572 KB |
Output is correct |