# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
299639 | 2020-09-15T11:19:51 Z | zwliew | Mountains (NOI20_mountains) | C++17 | 1419 ms | 23164 KB |
#include <algorithm> #include <array> #include <bitset> #include <chrono> #include <climits> #include <cmath> #include <cstring> #include <deque> #include <ext/pb_ds/assoc_container.hpp> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> // #include "bits/stdc++.h" using namespace std; #ifdef LOCAL #include "../../_library/cc/debug.h" #define FILE "test" #else #define debug(...) 0 #define FILE "cowjog" #endif #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> template <class T> using OrderStatisticTree = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; int main() { cin.tie(nullptr)->sync_with_stdio(false); if (fopen(FILE ".in", "r")) { freopen(FILE ".in", "r", stdin); freopen(FILE ".out", "w", stdout); } // Iterate through each possible middle mountain, and count the number of // mountains shorter than the middle mountain on both sides. int n; cin >> n; vector<int64_t> h(n); OrderStatisticTree<pair<int, int>> left, right; for (int i = 0; i < n; ++i) { cin >> h[i]; right.insert({h[i], i}); } int64_t ans = 0; for (int i = 0; i < n - 1; ++i) { right.erase(right.lower_bound({h[i], 0})); ans += (int64_t)left.order_of_key({h[i], 0}) * right.order_of_key({h[i], 0}); left.insert({h[i], i}); } cout << ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Incorrect | 1020 ms | 21496 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 403 ms | 21496 KB | Output is correct |
2 | Correct | 391 ms | 22008 KB | Output is correct |
3 | Correct | 362 ms | 22008 KB | Output is correct |
4 | Correct | 385 ms | 22008 KB | Output is correct |
5 | Correct | 367 ms | 22008 KB | Output is correct |
6 | Correct | 387 ms | 22008 KB | Output is correct |
7 | Correct | 406 ms | 22008 KB | Output is correct |
8 | Correct | 692 ms | 22264 KB | Output is correct |
9 | Correct | 706 ms | 22012 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 403 ms | 21496 KB | Output is correct |
2 | Correct | 391 ms | 22008 KB | Output is correct |
3 | Correct | 362 ms | 22008 KB | Output is correct |
4 | Correct | 385 ms | 22008 KB | Output is correct |
5 | Correct | 367 ms | 22008 KB | Output is correct |
6 | Correct | 387 ms | 22008 KB | Output is correct |
7 | Correct | 406 ms | 22008 KB | Output is correct |
8 | Correct | 692 ms | 22264 KB | Output is correct |
9 | Correct | 706 ms | 22012 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 779 ms | 22368 KB | Output is correct |
12 | Correct | 752 ms | 22264 KB | Output is correct |
13 | Correct | 763 ms | 22392 KB | Output is correct |
14 | Correct | 767 ms | 22264 KB | Output is correct |
15 | Correct | 781 ms | 22264 KB | Output is correct |
16 | Correct | 766 ms | 22264 KB | Output is correct |
17 | Correct | 765 ms | 22264 KB | Output is correct |
18 | Correct | 703 ms | 22268 KB | Output is correct |
19 | Correct | 709 ms | 22392 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 403 ms | 21496 KB | Output is correct |
2 | Correct | 391 ms | 22008 KB | Output is correct |
3 | Correct | 362 ms | 22008 KB | Output is correct |
4 | Correct | 385 ms | 22008 KB | Output is correct |
5 | Correct | 367 ms | 22008 KB | Output is correct |
6 | Correct | 387 ms | 22008 KB | Output is correct |
7 | Correct | 406 ms | 22008 KB | Output is correct |
8 | Correct | 692 ms | 22264 KB | Output is correct |
9 | Correct | 706 ms | 22012 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 779 ms | 22368 KB | Output is correct |
12 | Correct | 752 ms | 22264 KB | Output is correct |
13 | Correct | 763 ms | 22392 KB | Output is correct |
14 | Correct | 767 ms | 22264 KB | Output is correct |
15 | Correct | 781 ms | 22264 KB | Output is correct |
16 | Correct | 766 ms | 22264 KB | Output is correct |
17 | Correct | 765 ms | 22264 KB | Output is correct |
18 | Correct | 703 ms | 22268 KB | Output is correct |
19 | Correct | 709 ms | 22392 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 1075 ms | 23160 KB | Output is correct |
22 | Correct | 1419 ms | 23160 KB | Output is correct |
23 | Correct | 1060 ms | 23160 KB | Output is correct |
24 | Correct | 1070 ms | 23160 KB | Output is correct |
25 | Correct | 1069 ms | 23164 KB | Output is correct |
26 | Correct | 1049 ms | 23160 KB | Output is correct |
27 | Correct | 1077 ms | 23160 KB | Output is correct |
28 | Correct | 730 ms | 23160 KB | Output is correct |
29 | Correct | 728 ms | 23160 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Incorrect | 1020 ms | 21496 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |