답안 #405610

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
405610 2021-05-16T15:07:45 Z rqi Mountains (NOI20_mountains) C++14
100 / 100
622 ms 55280 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define f first
#define s second
#define ins insert

#define sz(x) (int)(x).size()

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

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

#define fbo find_by_order
#define ook order_of_key

const int mx = 300005;
ll H[mx];

int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> H[i];
	}
	map<ll, vi> vals;
	for(int i = 1; i <= n; i++){
		vals[H[i]].pb(i);
	}

	Tree<int> t;

	ll ans = 0;
	for(auto& u: vals){
		for(auto& pos: u.s){
			int ind = t.order_of_key(pos);
			ans+=ll(ind)*ll(sz(t)-ind);
		}
		for(auto& pos: u.s){
			t.ins(pos);
		}
	}
	cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 377 ms 55096 KB Output is correct
3 Correct 383 ms 55216 KB Output is correct
4 Correct 427 ms 55140 KB Output is correct
5 Correct 380 ms 55080 KB Output is correct
6 Correct 383 ms 55280 KB Output is correct
7 Correct 389 ms 55076 KB Output is correct
8 Correct 393 ms 55216 KB Output is correct
9 Correct 426 ms 39340 KB Output is correct
10 Correct 387 ms 39556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 216 ms 18588 KB Output is correct
2 Correct 211 ms 18500 KB Output is correct
3 Correct 207 ms 18480 KB Output is correct
4 Correct 210 ms 18492 KB Output is correct
5 Correct 210 ms 18460 KB Output is correct
6 Correct 208 ms 18508 KB Output is correct
7 Correct 212 ms 18480 KB Output is correct
8 Correct 279 ms 18416 KB Output is correct
9 Correct 270 ms 18492 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 216 ms 18588 KB Output is correct
2 Correct 211 ms 18500 KB Output is correct
3 Correct 207 ms 18480 KB Output is correct
4 Correct 210 ms 18492 KB Output is correct
5 Correct 210 ms 18460 KB Output is correct
6 Correct 208 ms 18508 KB Output is correct
7 Correct 212 ms 18480 KB Output is correct
8 Correct 279 ms 18416 KB Output is correct
9 Correct 270 ms 18492 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 236 ms 19148 KB Output is correct
12 Correct 228 ms 19048 KB Output is correct
13 Correct 214 ms 19140 KB Output is correct
14 Correct 214 ms 19136 KB Output is correct
15 Correct 219 ms 19044 KB Output is correct
16 Correct 220 ms 19160 KB Output is correct
17 Correct 216 ms 19140 KB Output is correct
18 Correct 324 ms 19132 KB Output is correct
19 Correct 315 ms 19140 KB Output is correct
20 Correct 1 ms 316 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 2 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 204 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 2 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 10 ms 2124 KB Output is correct
12 Correct 10 ms 2112 KB Output is correct
13 Correct 10 ms 2072 KB Output is correct
14 Correct 10 ms 2040 KB Output is correct
15 Correct 10 ms 2124 KB Output is correct
16 Correct 10 ms 2124 KB Output is correct
17 Correct 10 ms 2124 KB Output is correct
18 Correct 9 ms 1484 KB Output is correct
19 Correct 7 ms 972 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 216 ms 18588 KB Output is correct
2 Correct 211 ms 18500 KB Output is correct
3 Correct 207 ms 18480 KB Output is correct
4 Correct 210 ms 18492 KB Output is correct
5 Correct 210 ms 18460 KB Output is correct
6 Correct 208 ms 18508 KB Output is correct
7 Correct 212 ms 18480 KB Output is correct
8 Correct 279 ms 18416 KB Output is correct
9 Correct 270 ms 18492 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 236 ms 19148 KB Output is correct
12 Correct 228 ms 19048 KB Output is correct
13 Correct 214 ms 19140 KB Output is correct
14 Correct 214 ms 19136 KB Output is correct
15 Correct 219 ms 19044 KB Output is correct
16 Correct 220 ms 19160 KB Output is correct
17 Correct 216 ms 19140 KB Output is correct
18 Correct 324 ms 19132 KB Output is correct
19 Correct 315 ms 19140 KB Output is correct
20 Correct 1 ms 316 KB Output is correct
21 Correct 465 ms 29280 KB Output is correct
22 Correct 450 ms 29412 KB Output is correct
23 Correct 433 ms 29336 KB Output is correct
24 Correct 442 ms 29312 KB Output is correct
25 Correct 456 ms 29508 KB Output is correct
26 Correct 417 ms 29248 KB Output is correct
27 Correct 435 ms 29416 KB Output is correct
28 Correct 365 ms 29124 KB Output is correct
29 Correct 381 ms 29108 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 377 ms 55096 KB Output is correct
3 Correct 383 ms 55216 KB Output is correct
4 Correct 427 ms 55140 KB Output is correct
5 Correct 380 ms 55080 KB Output is correct
6 Correct 383 ms 55280 KB Output is correct
7 Correct 389 ms 55076 KB Output is correct
8 Correct 393 ms 55216 KB Output is correct
9 Correct 426 ms 39340 KB Output is correct
10 Correct 387 ms 39556 KB Output is correct
11 Correct 216 ms 18588 KB Output is correct
12 Correct 211 ms 18500 KB Output is correct
13 Correct 207 ms 18480 KB Output is correct
14 Correct 210 ms 18492 KB Output is correct
15 Correct 210 ms 18460 KB Output is correct
16 Correct 208 ms 18508 KB Output is correct
17 Correct 212 ms 18480 KB Output is correct
18 Correct 279 ms 18416 KB Output is correct
19 Correct 270 ms 18492 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 236 ms 19148 KB Output is correct
22 Correct 228 ms 19048 KB Output is correct
23 Correct 214 ms 19140 KB Output is correct
24 Correct 214 ms 19136 KB Output is correct
25 Correct 219 ms 19044 KB Output is correct
26 Correct 220 ms 19160 KB Output is correct
27 Correct 216 ms 19140 KB Output is correct
28 Correct 324 ms 19132 KB Output is correct
29 Correct 315 ms 19140 KB Output is correct
30 Correct 1 ms 316 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 2 ms 332 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 10 ms 2124 KB Output is correct
42 Correct 10 ms 2112 KB Output is correct
43 Correct 10 ms 2072 KB Output is correct
44 Correct 10 ms 2040 KB Output is correct
45 Correct 10 ms 2124 KB Output is correct
46 Correct 10 ms 2124 KB Output is correct
47 Correct 10 ms 2124 KB Output is correct
48 Correct 9 ms 1484 KB Output is correct
49 Correct 7 ms 972 KB Output is correct
50 Correct 1 ms 320 KB Output is correct
51 Correct 465 ms 29280 KB Output is correct
52 Correct 450 ms 29412 KB Output is correct
53 Correct 433 ms 29336 KB Output is correct
54 Correct 442 ms 29312 KB Output is correct
55 Correct 456 ms 29508 KB Output is correct
56 Correct 417 ms 29248 KB Output is correct
57 Correct 435 ms 29416 KB Output is correct
58 Correct 365 ms 29124 KB Output is correct
59 Correct 381 ms 29108 KB Output is correct
60 Correct 1 ms 204 KB Output is correct
61 Correct 607 ms 55204 KB Output is correct
62 Correct 622 ms 55164 KB Output is correct
63 Correct 581 ms 55236 KB Output is correct
64 Correct 574 ms 55064 KB Output is correct
65 Correct 606 ms 55212 KB Output is correct
66 Correct 611 ms 55168 KB Output is correct
67 Correct 596 ms 55272 KB Output is correct
68 Correct 531 ms 39412 KB Output is correct
69 Correct 476 ms 32916 KB Output is correct
70 Correct 1 ms 204 KB Output is correct