Submission #540994

# Submission time Handle Problem Language Result Execution time Memory
540994 2022-03-22T06:00:19 Z bayemirov Mountains (NOI20_mountains) C++17
0 / 100
738 ms 40176 KB
// bayemirov

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace __gnu_pbds;
using namespace std;


typedef long long ll;

typedef tree<
ll,
null_type,
less_equal<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int N = 4e5;

int n;
ll h[N], ans;
ordered_set a, b;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		if (i > 1)
			b.insert(h[i]);
	}
	a.insert(h[0]);
	for (int i = 1; i < n; i++) {
		int cnt_x = a.order_of_key(h[i]);
		int cnt_z = b.order_of_key(h[i]);
		//cout << i << ' ' << cnt_x << ' ' << cnt_z << "\n";
		ans += cnt_x*1ll*cnt_z;
		a.insert(h[i]);
		b.erase(b.find_by_order(h[i+1]));
	}
	cout << ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 738 ms 40176 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 279 ms 21444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 279 ms 21444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 279 ms 21444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 738 ms 40176 KB Output isn't correct
3 Halted 0 ms 0 KB -