| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 10074 | gs14004 | 공장 (KOI13_factory) | C++98 | 228 ms | 9016 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
int n, mp[1000005], t;
int c[500005];
struct f{
int tree[530000], lim;
void init(int n){
for (lim = 1; lim <= n+1; lim <<= 1);
}
void add(int x){
x++;
while(x <= lim){
tree[x]++;
x += x & -x;
}
}
int sum(int x){
x++;
int res = 0;
while(x){
res += tree[x];
x -= x & -x;
}
return res;
}
}bit;
int main(){
scanf("%d",&n);
for (int i=0; i<n; i++) {
scanf("%d",&t);
mp[t] = i;
}
for (int i=0; i<n; i++) {
scanf("%d",&t);
c[mp[t]] = i;
}
bit.init(n);
long long res = 0;
for (int i=0; i<n; i++) {
res += i - bit.sum(c[i]);
bit.add(c[i]);
}
printf("%lld",res);
}| # | 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... | ||||
