File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ /** THIS IS AN OUTPUT FILE. NOT EDIT THIS FILE DIRECTLY. **/
2
+ use proconio:: input;
3
+ use proconio:: marker:: * ;
4
+ use std:: marker:: PhantomData ;
5
+ use std:: cmp:: * ;
6
+ use std:: collections:: * ;
7
+
8
+ fn main ( ) {
9
+ input ! {
10
+ t: usize
11
+ }
12
+
13
+ for _ in 0 ..t {
14
+ helper ( ) ;
15
+ }
16
+ }
17
+
18
+ fn helper ( ) {
19
+ let mut p = 0 ;
20
+ let mut result = 1 ;
21
+
22
+ input ! {
23
+ n: usize ,
24
+ s: [ usize ; n]
25
+ }
26
+
27
+ let mut success = true ;
28
+ loop {
29
+ if 2 * s[ p] >= s[ n-1 ] {
30
+ result += 1 ;
31
+ break
32
+ }
33
+
34
+ match s
35
+ . iter ( )
36
+ . enumerate ( )
37
+ . filter ( |& ( _, & x) | x > s[ p] && x <= 2 * s[ p] )
38
+ . max_by_key ( |& ( _, & x) | x) {
39
+ Some ( ( i, _) ) => {
40
+ p = i;
41
+ result += 1 ;
42
+ }
43
+ None => {
44
+ println ! ( "-1" ) ;
45
+ success = false ;
46
+ break
47
+ }
48
+ }
49
+ }
50
+
51
+ if success {
52
+ println ! ( "{}" , result) ;
53
+ }
54
+ }
You can’t perform that action at this time.
0 commit comments