답안 #1101

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1101 2013-06-25T06:40:17 Z tncks0121 공장 (KOI13_factory) C++
9.4 / 20
249 ms 10840 KB
#include <stdio.h>
int n;
int val[1000007];
int seq[500007];
int bit[1048577], bin;
void put(int key)
{
int ind = bin+key-1;
while(ind)
{
bit[ind]++;
ind /= 2;
}
}
int sum(int left, int right)
{
int lind = bin+left-1;
int rind = bin+right-1;
int rval=0;
while(lind <= rind)
{
if(lind%2 == 1) rval += bit[lind];
if(rind%2 == 0) rval += bit[rind];
lind = (lind+1)/2;
rind = (rind-1)/2;
}return rval;
}
int main(void)
{
int i, v;
long long res=0;
scanf("%d", &n);
for(bin=1;bin<n;bin*=2);
for(i = 1; i <= n; i++)
scanf("%d", &seq[i]);
for(i = 1; i <= n; i++)
{
scanf("%d", &v);
val[v]= i;
}
for(i = 1; i <= n; i++)
seq[i] = val[seq[i]];
for(i = 1; i <= n; i++)
{
res += sum(seq[i]+1, n);
put(seq[i]);
}printf("%d\n", res);
return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 10840 KB Output is correct
2 Correct 0 ms 10840 KB Output is correct
3 Correct 0 ms 10840 KB Output is correct
4 Correct 0 ms 10840 KB Output is correct
5 Correct 0 ms 10840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 10840 KB Output is correct
2 Correct 0 ms 10840 KB Output is correct
3 Correct 4 ms 10840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 10840 KB Output is correct
2 Correct 24 ms 10840 KB Output is correct
3 Correct 42 ms 10840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 57 ms 10840 KB Output isn't correct
2 Halted 0 ms 0 KB -
3 Halted 0 ms 0 KB -
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 249 ms 10840 KB Output isn't correct
2 Halted 0 ms 0 KB -
3 Halted 0 ms 0 KB -
4 Halted 0 ms 0 KB -
5 Halted 0 ms 0 KB -
6 Halted 0 ms 0 KB -