# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
82845 | leejseo | 공장 (KOI13_factory) | C++11 | 256 ms | 62484 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
typedef struct BIT{
lld tree[524288];
const int MAXN = 524288;
lld sum(int i){
lld ans = 0;
while (i > 0){
ans += tree[i];
i -= (i & -i);
}
return ans;
}
void update(int i, lld diff){
while (i < MAXN){
tree[i] += diff;
i += (i & -i);
}
}
} BIT;
int N, I[1000001];
vector<int> L;
BIT tree;
void input(){
scanf("%d", &N);
for (int i=1; i<=N; i++){
int temp;
scanf("%d", &temp);
I[temp] = i;
}
L.push_back(-1);
for (int i=1; i<=N; i++){
int temp;
scanf("%d", &temp);
L.push_back(I[temp]);
}
}
lld solve(){
lld ans = 0;
for (int i=1; i<=N; i++){
ans += i - tree.sum(L[i]) - 1;
tree.update(L[i], 1);
}
return ans;
}
int main(void){
input();
printf("%lld\n", solve());
}
컴파일 시 표준 에러 (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... |