Submission #1091568

# Submission time Handle Problem Language Result Execution time Memory
1091568 2024-09-21T09:46:47 Z _rain_ Mountains (NOI20_mountains) C++14
24 / 100
95 ms 8180 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define fixbug true

const int maxn = 3e5;
int h[maxn+2],BIT[maxn+2],ans[maxn+2],n;
int Right[maxn+2],Left[maxn+2];
void add(int p , int val){
	for (; p <= n; p += p&-p)
		BIT[p] += val;
	return;
}
int Get(int p){
	int sum = 0;
	for (; p; p -= p&-p)
		sum += BIT[p];
	return sum;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	cin >> n;
	vector<int>v;
	for (int i = 1; i <= n; ++i){
		cin >> h[i];
		v.push_back(h[i]);
	}
	sort(v.begin(),v.end());
	v.resize(unique(v.begin(),v.end())-v.begin());
	for (int i = 1; i <= n; ++i)
		h[i] = upper_bound(v.begin(),v.end(),h[i])-v.begin();
	for (int i = 1; i <= n; ++i){
		add(h[i],1);
		Left[i] += Get(h[i]-1);
	}
	memset(BIT,0,sizeof BIT);
	for (int i = n; i >= 1; --i){
		add(h[i],1);
		Right[i] += Get(h[i]-1);
	}
	ll ans = 0;
	for (int i = 1; i <= n; ++i){
		ans += (ll)Left[i]*Right[i];
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1628 KB Output is correct
2 Correct 28 ms 6408 KB Output is correct
3 Correct 29 ms 6348 KB Output is correct
4 Correct 30 ms 6344 KB Output is correct
5 Correct 27 ms 6344 KB Output is correct
6 Correct 29 ms 6344 KB Output is correct
7 Correct 27 ms 6472 KB Output is correct
8 Correct 29 ms 6424 KB Output is correct
9 Correct 29 ms 6344 KB Output is correct
10 Correct 29 ms 6344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 6860 KB Output is correct
2 Correct 41 ms 6896 KB Output is correct
3 Correct 43 ms 6852 KB Output is correct
4 Correct 45 ms 6848 KB Output is correct
5 Correct 43 ms 6928 KB Output is correct
6 Correct 38 ms 7028 KB Output is correct
7 Correct 41 ms 6848 KB Output is correct
8 Correct 40 ms 6848 KB Output is correct
9 Correct 36 ms 6868 KB Output is correct
10 Correct 1 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 6860 KB Output is correct
2 Correct 41 ms 6896 KB Output is correct
3 Correct 43 ms 6852 KB Output is correct
4 Correct 45 ms 6848 KB Output is correct
5 Correct 43 ms 6928 KB Output is correct
6 Correct 38 ms 7028 KB Output is correct
7 Correct 41 ms 6848 KB Output is correct
8 Correct 40 ms 6848 KB Output is correct
9 Correct 36 ms 6868 KB Output is correct
10 Correct 1 ms 1628 KB Output is correct
11 Correct 50 ms 7136 KB Output is correct
12 Correct 50 ms 7136 KB Output is correct
13 Correct 49 ms 7112 KB Output is correct
14 Correct 48 ms 7112 KB Output is correct
15 Correct 58 ms 7140 KB Output is correct
16 Correct 48 ms 7112 KB Output is correct
17 Correct 48 ms 7116 KB Output is correct
18 Correct 31 ms 7116 KB Output is correct
19 Correct 31 ms 7124 KB Output is correct
20 Correct 1 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 40 ms 6860 KB Output is correct
2 Correct 41 ms 6896 KB Output is correct
3 Correct 43 ms 6852 KB Output is correct
4 Correct 45 ms 6848 KB Output is correct
5 Correct 43 ms 6928 KB Output is correct
6 Correct 38 ms 7028 KB Output is correct
7 Correct 41 ms 6848 KB Output is correct
8 Correct 40 ms 6848 KB Output is correct
9 Correct 36 ms 6868 KB Output is correct
10 Correct 1 ms 1628 KB Output is correct
11 Correct 50 ms 7136 KB Output is correct
12 Correct 50 ms 7136 KB Output is correct
13 Correct 49 ms 7112 KB Output is correct
14 Correct 48 ms 7112 KB Output is correct
15 Correct 58 ms 7140 KB Output is correct
16 Correct 48 ms 7112 KB Output is correct
17 Correct 48 ms 7116 KB Output is correct
18 Correct 31 ms 7116 KB Output is correct
19 Correct 31 ms 7124 KB Output is correct
20 Correct 1 ms 1628 KB Output is correct
21 Correct 86 ms 8136 KB Output is correct
22 Correct 88 ms 8180 KB Output is correct
23 Correct 87 ms 8136 KB Output is correct
24 Correct 86 ms 8136 KB Output is correct
25 Correct 95 ms 8000 KB Output is correct
26 Correct 94 ms 8140 KB Output is correct
27 Correct 87 ms 8132 KB Output is correct
28 Correct 42 ms 8132 KB Output is correct
29 Correct 41 ms 8132 KB Output is correct
30 Correct 1 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1628 KB Output is correct
2 Correct 28 ms 6408 KB Output is correct
3 Correct 29 ms 6348 KB Output is correct
4 Correct 30 ms 6344 KB Output is correct
5 Correct 27 ms 6344 KB Output is correct
6 Correct 29 ms 6344 KB Output is correct
7 Correct 27 ms 6472 KB Output is correct
8 Correct 29 ms 6424 KB Output is correct
9 Correct 29 ms 6344 KB Output is correct
10 Correct 29 ms 6344 KB Output is correct
11 Correct 40 ms 6860 KB Output is correct
12 Correct 41 ms 6896 KB Output is correct
13 Correct 43 ms 6852 KB Output is correct
14 Correct 45 ms 6848 KB Output is correct
15 Correct 43 ms 6928 KB Output is correct
16 Correct 38 ms 7028 KB Output is correct
17 Correct 41 ms 6848 KB Output is correct
18 Correct 40 ms 6848 KB Output is correct
19 Correct 36 ms 6868 KB Output is correct
20 Correct 1 ms 1628 KB Output is correct
21 Correct 50 ms 7136 KB Output is correct
22 Correct 50 ms 7136 KB Output is correct
23 Correct 49 ms 7112 KB Output is correct
24 Correct 48 ms 7112 KB Output is correct
25 Correct 58 ms 7140 KB Output is correct
26 Correct 48 ms 7112 KB Output is correct
27 Correct 48 ms 7116 KB Output is correct
28 Correct 31 ms 7116 KB Output is correct
29 Correct 31 ms 7124 KB Output is correct
30 Correct 1 ms 1628 KB Output is correct
31 Incorrect 1 ms 1640 KB Output isn't correct
32 Halted 0 ms 0 KB -