답안 #383313

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
383313 2021-03-29T14:55:23 Z MODDI Mountains (NOI20_mountains) C++14
24 / 100
833 ms 107996 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
int n;
vl arr;
vector<ll> tree[12 * 100000];
void build(int node, int l, int r){
	if(l == r)
		tree[node].pb(arr[l]);
	else{
		ll mid = (l + r) / 2;
		build(node * 2, l, mid);
		build(node * 2 + 1, mid + 1, r);
		merge(tree[node * 2].begin(), tree[node * 2].end(), tree[node * 2 + 1].begin(), tree[node * 2 + 1].end(), back_inserter(tree[node]));
	}
}
ll query(int node, int l, int r, int L, int R, int k){
	if(r < L || l > R)	return 0;
	if(L <= l && r <= R){
		return lower_bound(tree[node].begin(), tree[node].end(), k) -tree[node].begin();
	}
	int mid = (l + r) / 2;
	int left = query(node  * 2, l, mid, L, R, k), right = query(node * 2 + 1, mid + 1, r, L, R, k);
	return left + right;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i = 0; i < n; i++){
		ll a;
		cin>>a;
		arr.pb(a);
	}
	build(1, 0, n - 1);
	ll rez = 0;
	for(int i =1; i < n - 1; i++){
		ll left = query(1, 0, n - 1, 0, i, arr[i]);
		ll right = query(1, 0, n - 1, i, n - 1, arr[i]);
		if(left > 0 && right > 0)
			rez += (left * right);
	}
	cout<<rez<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 28524 KB Output is correct
2 Correct 496 ms 107868 KB Output is correct
3 Correct 503 ms 107868 KB Output is correct
4 Correct 490 ms 107760 KB Output is correct
5 Correct 490 ms 107740 KB Output is correct
6 Correct 493 ms 107996 KB Output is correct
7 Correct 491 ms 107692 KB Output is correct
8 Correct 501 ms 107868 KB Output is correct
9 Correct 500 ms 107868 KB Output is correct
10 Correct 503 ms 107740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 477 ms 107852 KB Output is correct
2 Correct 477 ms 107740 KB Output is correct
3 Correct 479 ms 107876 KB Output is correct
4 Correct 479 ms 107996 KB Output is correct
5 Correct 477 ms 107996 KB Output is correct
6 Correct 480 ms 107828 KB Output is correct
7 Correct 479 ms 107740 KB Output is correct
8 Correct 478 ms 107740 KB Output is correct
9 Correct 458 ms 107996 KB Output is correct
10 Correct 19 ms 28524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 477 ms 107852 KB Output is correct
2 Correct 477 ms 107740 KB Output is correct
3 Correct 479 ms 107876 KB Output is correct
4 Correct 479 ms 107996 KB Output is correct
5 Correct 477 ms 107996 KB Output is correct
6 Correct 480 ms 107828 KB Output is correct
7 Correct 479 ms 107740 KB Output is correct
8 Correct 478 ms 107740 KB Output is correct
9 Correct 458 ms 107996 KB Output is correct
10 Correct 19 ms 28524 KB Output is correct
11 Correct 751 ms 107740 KB Output is correct
12 Correct 745 ms 107792 KB Output is correct
13 Correct 753 ms 107868 KB Output is correct
14 Correct 730 ms 107740 KB Output is correct
15 Correct 775 ms 107868 KB Output is correct
16 Correct 736 ms 107792 KB Output is correct
17 Correct 732 ms 107996 KB Output is correct
18 Correct 440 ms 107740 KB Output is correct
19 Correct 488 ms 107792 KB Output is correct
20 Correct 21 ms 28524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 28524 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 28524 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 477 ms 107852 KB Output is correct
2 Correct 477 ms 107740 KB Output is correct
3 Correct 479 ms 107876 KB Output is correct
4 Correct 479 ms 107996 KB Output is correct
5 Correct 477 ms 107996 KB Output is correct
6 Correct 480 ms 107828 KB Output is correct
7 Correct 479 ms 107740 KB Output is correct
8 Correct 478 ms 107740 KB Output is correct
9 Correct 458 ms 107996 KB Output is correct
10 Correct 19 ms 28524 KB Output is correct
11 Correct 751 ms 107740 KB Output is correct
12 Correct 745 ms 107792 KB Output is correct
13 Correct 753 ms 107868 KB Output is correct
14 Correct 730 ms 107740 KB Output is correct
15 Correct 775 ms 107868 KB Output is correct
16 Correct 736 ms 107792 KB Output is correct
17 Correct 732 ms 107996 KB Output is correct
18 Correct 440 ms 107740 KB Output is correct
19 Correct 488 ms 107792 KB Output is correct
20 Correct 21 ms 28524 KB Output is correct
21 Correct 819 ms 107724 KB Output is correct
22 Correct 833 ms 107740 KB Output is correct
23 Correct 824 ms 107996 KB Output is correct
24 Correct 824 ms 107868 KB Output is correct
25 Correct 814 ms 107868 KB Output is correct
26 Correct 813 ms 107792 KB Output is correct
27 Correct 820 ms 107792 KB Output is correct
28 Correct 445 ms 107892 KB Output is correct
29 Correct 446 ms 107868 KB Output is correct
30 Correct 19 ms 28524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 28524 KB Output is correct
2 Correct 496 ms 107868 KB Output is correct
3 Correct 503 ms 107868 KB Output is correct
4 Correct 490 ms 107760 KB Output is correct
5 Correct 490 ms 107740 KB Output is correct
6 Correct 493 ms 107996 KB Output is correct
7 Correct 491 ms 107692 KB Output is correct
8 Correct 501 ms 107868 KB Output is correct
9 Correct 500 ms 107868 KB Output is correct
10 Correct 503 ms 107740 KB Output is correct
11 Correct 477 ms 107852 KB Output is correct
12 Correct 477 ms 107740 KB Output is correct
13 Correct 479 ms 107876 KB Output is correct
14 Correct 479 ms 107996 KB Output is correct
15 Correct 477 ms 107996 KB Output is correct
16 Correct 480 ms 107828 KB Output is correct
17 Correct 479 ms 107740 KB Output is correct
18 Correct 478 ms 107740 KB Output is correct
19 Correct 458 ms 107996 KB Output is correct
20 Correct 19 ms 28524 KB Output is correct
21 Correct 751 ms 107740 KB Output is correct
22 Correct 745 ms 107792 KB Output is correct
23 Correct 753 ms 107868 KB Output is correct
24 Correct 730 ms 107740 KB Output is correct
25 Correct 775 ms 107868 KB Output is correct
26 Correct 736 ms 107792 KB Output is correct
27 Correct 732 ms 107996 KB Output is correct
28 Correct 440 ms 107740 KB Output is correct
29 Correct 488 ms 107792 KB Output is correct
30 Correct 21 ms 28524 KB Output is correct
31 Incorrect 19 ms 28524 KB Output isn't correct
32 Halted 0 ms 0 KB -