# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
884043 | vjudge1 | Bubble Sort 2 (JOI18_bubblesort2) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "bubblesort2"
using namespace std;
int aint[8000 * 4 + 5];
void update(int nod, int st, int dr, int poz, int val)
{
if(st == dr)
{
aint[nod] += val;
return;
}
int mij = (st + dr) / 2;
if(poz <= mij) update(nod * 2, st, mij, poz, val);
else update(nod * 2 + 1, mij + 1, dr, poz, val);
aint[nod] = max(aint[nod * 2], aint[nod * 2 + 1]);
}
vector<int> countScans(vector<int> a, vector<int> x, vector<int> v)
{
int rez = 0;
int n = a.size();
for(int i = 0; i < n; i++)
for(int j = i - 1; j >= 0; j--)
if(a[j] > a[i])
update(1, 1, n, i + 1, 1);