File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-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
+ n: usize ,
11
+ a: [ usize ; n]
12
+ }
13
+
14
+ let mut vec = vec ! [ ] ;
15
+ let mut rev = '<' ;
16
+ let mut count = 0 ;
17
+ for i in 0 ..n-1 {
18
+ if a[ i] < a[ i+1 ] {
19
+ if rev == '>' {
20
+ vec. push ( count) ;
21
+ rev = '<' ;
22
+ count = 0 ;
23
+ }
24
+ } else {
25
+ if rev == '<' {
26
+ vec. push ( count) ;
27
+ rev = '>' ;
28
+ count = 0 ;
29
+ }
30
+ }
31
+ count += 1 ;
32
+ }
33
+
34
+ vec. push ( count) ;
35
+ if rev == '>' {
36
+ vec. push ( 0 ) ;
37
+ }
38
+
39
+ let mut result = 0usize ;
40
+ for i in ( 2 ..vec. len ( ) ) . step_by ( 2 ) {
41
+ result += vec[ i] * vec[ i-2 ] ;
42
+ }
43
+
44
+ println ! ( "{}" , result) ;
45
+ }
You can’t perform that action at this time.
0 commit comments