Submission #7411

# Submission time Handle Problem Language Result Execution time Memory
7411 2014-08-05T04:14:44 Z gs13068 공장 (KOI13_factory) C++
20 / 20
244 ms 6948 KB
#include<cstdio>

int p[1000001];

int BIT[500001];

void update(int x){while(x<=500000){BIT[x]++;x+=x&-x;}}
int sum(int x){int y=0;while(x){y+=BIT[x];x-=x&-x;}return y;}

int main()
{
  long long r=0;
  int i,n,t;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
    scanf("%d",&t);
    p[t]=i;
  }
  for(i=1;i<=n;i++)
  {
    scanf("%d",&t);
    update(p[t]);
    r+=i-sum(p[t]);
  }
  printf("%lld",r);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6948 KB Output is correct
2 Correct 0 ms 6948 KB Output is correct
3 Correct 0 ms 6948 KB Output is correct
4 Correct 0 ms 6948 KB Output is correct
5 Correct 0 ms 6948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6948 KB Output is correct
2 Correct 4 ms 6948 KB Output is correct
3 Correct 8 ms 6948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 6948 KB Output is correct
2 Correct 24 ms 6948 KB Output is correct
3 Correct 24 ms 6948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 6948 KB Output is correct
2 Correct 76 ms 6948 KB Output is correct
3 Correct 100 ms 6948 KB Output is correct
4 Correct 152 ms 6948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 184 ms 6948 KB Output is correct
2 Correct 228 ms 6948 KB Output is correct
3 Correct 208 ms 6948 KB Output is correct
4 Correct 240 ms 6948 KB Output is correct
5 Correct 244 ms 6948 KB Output is correct
6 Correct 244 ms 6948 KB Output is correct