답안 #259076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
259076 2020-08-07T06:54:49 Z ryangohca Mountains (NOI20_mountains) C++17
100 / 100
1321 ms 27360 KB
#include <bits/stdc++.h>
#define pii pair<int, int>
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<long long, int>, null_type, less<pair<long long, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
main(){
	ordered_set left1, right1;
	int n; cin >> n;
	vector<long long> nums;
	for (int i = 0; i < n; i++){
		long long g; cin >> g;
		nums.push_back(g);
		right1.insert({g, i});
	}
	long long ans = 0;
	for (int i = 0; i < n; i++){
		right1.erase({nums[i], i});
		ans += left1.order_of_key({nums[i], 0LL}) * right1.order_of_key({nums[i], 0LL});
		left1.insert({nums[i], i});
	}
	cout << ans << endl;
}

Compilation message

Mountains.cpp:11:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 866 ms 27100 KB Output is correct
3 Correct 834 ms 27232 KB Output is correct
4 Correct 838 ms 27072 KB Output is correct
5 Correct 831 ms 27348 KB Output is correct
6 Correct 826 ms 27228 KB Output is correct
7 Correct 844 ms 27096 KB Output is correct
8 Correct 843 ms 27064 KB Output is correct
9 Correct 954 ms 27100 KB Output is correct
10 Correct 870 ms 26972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 424 ms 22116 KB Output is correct
2 Correct 448 ms 22124 KB Output is correct
3 Correct 394 ms 22112 KB Output is correct
4 Correct 456 ms 22244 KB Output is correct
5 Correct 421 ms 22112 KB Output is correct
6 Correct 424 ms 22116 KB Output is correct
7 Correct 450 ms 22240 KB Output is correct
8 Correct 634 ms 22260 KB Output is correct
9 Correct 616 ms 22212 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 424 ms 22116 KB Output is correct
2 Correct 448 ms 22124 KB Output is correct
3 Correct 394 ms 22112 KB Output is correct
4 Correct 456 ms 22244 KB Output is correct
5 Correct 421 ms 22112 KB Output is correct
6 Correct 424 ms 22116 KB Output is correct
7 Correct 450 ms 22240 KB Output is correct
8 Correct 634 ms 22260 KB Output is correct
9 Correct 616 ms 22212 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 840 ms 22404 KB Output is correct
12 Correct 850 ms 22504 KB Output is correct
13 Correct 848 ms 22476 KB Output is correct
14 Correct 798 ms 22396 KB Output is correct
15 Correct 771 ms 22496 KB Output is correct
16 Correct 876 ms 22396 KB Output is correct
17 Correct 740 ms 22348 KB Output is correct
18 Correct 648 ms 22364 KB Output is correct
19 Correct 616 ms 22492 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 21 ms 1268 KB Output is correct
12 Correct 21 ms 1152 KB Output is correct
13 Correct 21 ms 1272 KB Output is correct
14 Correct 20 ms 1272 KB Output is correct
15 Correct 21 ms 1280 KB Output is correct
16 Correct 21 ms 1276 KB Output is correct
17 Correct 21 ms 1280 KB Output is correct
18 Correct 21 ms 1280 KB Output is correct
19 Correct 14 ms 1024 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 424 ms 22116 KB Output is correct
2 Correct 448 ms 22124 KB Output is correct
3 Correct 394 ms 22112 KB Output is correct
4 Correct 456 ms 22244 KB Output is correct
5 Correct 421 ms 22112 KB Output is correct
6 Correct 424 ms 22116 KB Output is correct
7 Correct 450 ms 22240 KB Output is correct
8 Correct 634 ms 22260 KB Output is correct
9 Correct 616 ms 22212 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 840 ms 22404 KB Output is correct
12 Correct 850 ms 22504 KB Output is correct
13 Correct 848 ms 22476 KB Output is correct
14 Correct 798 ms 22396 KB Output is correct
15 Correct 771 ms 22496 KB Output is correct
16 Correct 876 ms 22396 KB Output is correct
17 Correct 740 ms 22348 KB Output is correct
18 Correct 648 ms 22364 KB Output is correct
19 Correct 616 ms 22492 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1140 ms 23276 KB Output is correct
22 Correct 1114 ms 23280 KB Output is correct
23 Correct 1081 ms 23392 KB Output is correct
24 Correct 1079 ms 23516 KB Output is correct
25 Correct 1093 ms 23388 KB Output is correct
26 Correct 1085 ms 23516 KB Output is correct
27 Correct 1122 ms 23280 KB Output is correct
28 Correct 679 ms 23260 KB Output is correct
29 Correct 673 ms 23388 KB Output is correct
30 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 866 ms 27100 KB Output is correct
3 Correct 834 ms 27232 KB Output is correct
4 Correct 838 ms 27072 KB Output is correct
5 Correct 831 ms 27348 KB Output is correct
6 Correct 826 ms 27228 KB Output is correct
7 Correct 844 ms 27096 KB Output is correct
8 Correct 843 ms 27064 KB Output is correct
9 Correct 954 ms 27100 KB Output is correct
10 Correct 870 ms 26972 KB Output is correct
11 Correct 424 ms 22116 KB Output is correct
12 Correct 448 ms 22124 KB Output is correct
13 Correct 394 ms 22112 KB Output is correct
14 Correct 456 ms 22244 KB Output is correct
15 Correct 421 ms 22112 KB Output is correct
16 Correct 424 ms 22116 KB Output is correct
17 Correct 450 ms 22240 KB Output is correct
18 Correct 634 ms 22260 KB Output is correct
19 Correct 616 ms 22212 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 840 ms 22404 KB Output is correct
22 Correct 850 ms 22504 KB Output is correct
23 Correct 848 ms 22476 KB Output is correct
24 Correct 798 ms 22396 KB Output is correct
25 Correct 771 ms 22496 KB Output is correct
26 Correct 876 ms 22396 KB Output is correct
27 Correct 740 ms 22348 KB Output is correct
28 Correct 648 ms 22364 KB Output is correct
29 Correct 616 ms 22492 KB Output is correct
30 Correct 0 ms 256 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 2 ms 380 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 1 ms 384 KB Output is correct
39 Correct 1 ms 384 KB Output is correct
40 Correct 0 ms 256 KB Output is correct
41 Correct 21 ms 1268 KB Output is correct
42 Correct 21 ms 1152 KB Output is correct
43 Correct 21 ms 1272 KB Output is correct
44 Correct 20 ms 1272 KB Output is correct
45 Correct 21 ms 1280 KB Output is correct
46 Correct 21 ms 1276 KB Output is correct
47 Correct 21 ms 1280 KB Output is correct
48 Correct 21 ms 1280 KB Output is correct
49 Correct 14 ms 1024 KB Output is correct
50 Correct 1 ms 256 KB Output is correct
51 Correct 1140 ms 23276 KB Output is correct
52 Correct 1114 ms 23280 KB Output is correct
53 Correct 1081 ms 23392 KB Output is correct
54 Correct 1079 ms 23516 KB Output is correct
55 Correct 1093 ms 23388 KB Output is correct
56 Correct 1085 ms 23516 KB Output is correct
57 Correct 1122 ms 23280 KB Output is correct
58 Correct 679 ms 23260 KB Output is correct
59 Correct 673 ms 23388 KB Output is correct
60 Correct 1 ms 256 KB Output is correct
61 Correct 1276 ms 27096 KB Output is correct
62 Correct 1244 ms 27100 KB Output is correct
63 Correct 1230 ms 27228 KB Output is correct
64 Correct 1321 ms 26972 KB Output is correct
65 Correct 1320 ms 27228 KB Output is correct
66 Correct 1231 ms 27360 KB Output is correct
67 Correct 1272 ms 26972 KB Output is correct
68 Correct 1216 ms 27040 KB Output is correct
69 Correct 1018 ms 23388 KB Output is correct
70 Correct 1 ms 256 KB Output is correct