# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
583504 | Kanaifu | Mountains (NOI20_mountains) | C++17 | 93 ms | 7416 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
int tree[300001], h[300001];
int n;
int sum(int ind)
{
int zbir = 0;
while (ind > 0)
{
zbir += tree[ind];
ind = (ind)&(ind-1);
}
return zbir;
}
void update(int ind)
{
while (ind <= n)
{
tree[ind]++;
ind += (ind & (-ind));
}
}
int query(int left, int right)
{
return (sum(right) - sum(left - 1));
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long brojac = 0;
memset(tree, 0, sizeof(tree));
vector <int> reset;
vector <pair<int, int>> order;
cin>>n;
for (int i=1; i<=n; i++)
{
cin>>h[i];
order.pb({h[i], i});
}
sort(order.begin(), order.end());
int last = -1;
for (int i=0; i<order.size(); i++)
{
if (order[i].fr != last)
{
for (int el : reset)
{
update(el);
}
reset.clear();
}
brojac += ((long long)(query(1, order[i].sc-1)))*((long long)query(order[i].sc+1, n));
reset.pb(order[i].sc);
last = order[i].fr;
}
cout<<brojac;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |