답안 #439659

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
439659 2021-06-30T13:17:05 Z MohamedAhmed04 Mountains (NOI20_mountains) C++14
100 / 100
978 ms 31796 KB
#include <bits/stdc++.h>

using namespace std ;

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace __gnu_pbds;

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

const int MAX = 3e5 + 10 ;

long long arr[MAX] , pref[MAX] , suff[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	ordered_set< pair<long long , int> >s ;
	for(int i = 0 ; i < n ; ++i)
	{
		pref[i] = s.order_of_key({arr[i]-1 , 1e9}) ;
		s.insert({arr[i] , i}) ;
	}
	s.clear() ;
	for(int i = n-1 ; i >= 0 ; --i)
	{
		suff[i] = s.order_of_key({arr[i]-1 , 1e9}) ;
		s.insert({arr[i] , i}) ;
	}
	long long ans = 0 ;
	for(int i = 0 ; i < n ; ++i)
		ans += pref[i] * suff[i] ;
	return cout<<ans<<"\n" , 0 ; 
}		
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 495 ms 31544 KB Output is correct
3 Correct 553 ms 31572 KB Output is correct
4 Correct 494 ms 31572 KB Output is correct
5 Correct 540 ms 31560 KB Output is correct
6 Correct 489 ms 31664 KB Output is correct
7 Correct 527 ms 31660 KB Output is correct
8 Correct 502 ms 31664 KB Output is correct
9 Correct 551 ms 31708 KB Output is correct
10 Correct 533 ms 31764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 383 ms 26688 KB Output is correct
2 Correct 359 ms 26724 KB Output is correct
3 Correct 404 ms 26632 KB Output is correct
4 Correct 358 ms 26688 KB Output is correct
5 Correct 369 ms 26692 KB Output is correct
6 Correct 378 ms 26736 KB Output is correct
7 Correct 359 ms 26700 KB Output is correct
8 Correct 433 ms 26700 KB Output is correct
9 Correct 428 ms 26632 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 383 ms 26688 KB Output is correct
2 Correct 359 ms 26724 KB Output is correct
3 Correct 404 ms 26632 KB Output is correct
4 Correct 358 ms 26688 KB Output is correct
5 Correct 369 ms 26692 KB Output is correct
6 Correct 378 ms 26736 KB Output is correct
7 Correct 359 ms 26700 KB Output is correct
8 Correct 433 ms 26700 KB Output is correct
9 Correct 428 ms 26632 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 714 ms 26900 KB Output is correct
12 Correct 741 ms 26976 KB Output is correct
13 Correct 755 ms 27000 KB Output is correct
14 Correct 736 ms 26980 KB Output is correct
15 Correct 718 ms 27044 KB Output is correct
16 Correct 727 ms 26984 KB Output is correct
17 Correct 707 ms 26904 KB Output is correct
18 Correct 441 ms 26904 KB Output is correct
19 Correct 453 ms 26988 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 11 ms 1356 KB Output is correct
12 Correct 11 ms 1328 KB Output is correct
13 Correct 11 ms 1356 KB Output is correct
14 Correct 11 ms 1356 KB Output is correct
15 Correct 11 ms 1268 KB Output is correct
16 Correct 11 ms 1356 KB Output is correct
17 Correct 11 ms 1368 KB Output is correct
18 Correct 11 ms 1328 KB Output is correct
19 Correct 10 ms 1100 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 383 ms 26688 KB Output is correct
2 Correct 359 ms 26724 KB Output is correct
3 Correct 404 ms 26632 KB Output is correct
4 Correct 358 ms 26688 KB Output is correct
5 Correct 369 ms 26692 KB Output is correct
6 Correct 378 ms 26736 KB Output is correct
7 Correct 359 ms 26700 KB Output is correct
8 Correct 433 ms 26700 KB Output is correct
9 Correct 428 ms 26632 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 714 ms 26900 KB Output is correct
12 Correct 741 ms 26976 KB Output is correct
13 Correct 755 ms 27000 KB Output is correct
14 Correct 736 ms 26980 KB Output is correct
15 Correct 718 ms 27044 KB Output is correct
16 Correct 727 ms 26984 KB Output is correct
17 Correct 707 ms 26904 KB Output is correct
18 Correct 441 ms 26904 KB Output is correct
19 Correct 453 ms 26988 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 919 ms 27836 KB Output is correct
22 Correct 864 ms 27760 KB Output is correct
23 Correct 886 ms 27824 KB Output is correct
24 Correct 967 ms 27816 KB Output is correct
25 Correct 921 ms 27860 KB Output is correct
26 Correct 929 ms 27784 KB Output is correct
27 Correct 978 ms 27832 KB Output is correct
28 Correct 466 ms 27848 KB Output is correct
29 Correct 478 ms 27912 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 495 ms 31544 KB Output is correct
3 Correct 553 ms 31572 KB Output is correct
4 Correct 494 ms 31572 KB Output is correct
5 Correct 540 ms 31560 KB Output is correct
6 Correct 489 ms 31664 KB Output is correct
7 Correct 527 ms 31660 KB Output is correct
8 Correct 502 ms 31664 KB Output is correct
9 Correct 551 ms 31708 KB Output is correct
10 Correct 533 ms 31764 KB Output is correct
11 Correct 383 ms 26688 KB Output is correct
12 Correct 359 ms 26724 KB Output is correct
13 Correct 404 ms 26632 KB Output is correct
14 Correct 358 ms 26688 KB Output is correct
15 Correct 369 ms 26692 KB Output is correct
16 Correct 378 ms 26736 KB Output is correct
17 Correct 359 ms 26700 KB Output is correct
18 Correct 433 ms 26700 KB Output is correct
19 Correct 428 ms 26632 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 714 ms 26900 KB Output is correct
22 Correct 741 ms 26976 KB Output is correct
23 Correct 755 ms 27000 KB Output is correct
24 Correct 736 ms 26980 KB Output is correct
25 Correct 718 ms 27044 KB Output is correct
26 Correct 727 ms 26984 KB Output is correct
27 Correct 707 ms 26904 KB Output is correct
28 Correct 441 ms 26904 KB Output is correct
29 Correct 453 ms 26988 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 11 ms 1356 KB Output is correct
42 Correct 11 ms 1328 KB Output is correct
43 Correct 11 ms 1356 KB Output is correct
44 Correct 11 ms 1356 KB Output is correct
45 Correct 11 ms 1268 KB Output is correct
46 Correct 11 ms 1356 KB Output is correct
47 Correct 11 ms 1368 KB Output is correct
48 Correct 11 ms 1328 KB Output is correct
49 Correct 10 ms 1100 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 919 ms 27836 KB Output is correct
52 Correct 864 ms 27760 KB Output is correct
53 Correct 886 ms 27824 KB Output is correct
54 Correct 967 ms 27816 KB Output is correct
55 Correct 921 ms 27860 KB Output is correct
56 Correct 929 ms 27784 KB Output is correct
57 Correct 978 ms 27832 KB Output is correct
58 Correct 466 ms 27848 KB Output is correct
59 Correct 478 ms 27912 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 816 ms 31696 KB Output is correct
62 Correct 907 ms 31796 KB Output is correct
63 Correct 962 ms 31668 KB Output is correct
64 Correct 858 ms 31552 KB Output is correct
65 Correct 868 ms 31644 KB Output is correct
66 Correct 899 ms 31664 KB Output is correct
67 Correct 873 ms 31540 KB Output is correct
68 Correct 878 ms 31620 KB Output is correct
69 Correct 845 ms 27880 KB Output is correct
70 Correct 1 ms 276 KB Output is correct