Submission #1116

#TimeUsernameProblemLanguageResultExecution timeMemory
1116ainta공장 (KOI13_factory)C++98
20 / 20
263 ms8696 KiB
#include<stdio.h> int N,ord[1000001],BIT[500010],i,w[500010]; long long Res; int Sum(int a){ int s=0; while(a){ s+=BIT[a]; a=a&(a-1); } return s; } void add(int a){ while(a<=N){ BIT[a]++; a+=a&-a; } } int main() { int a; scanf("%d",&N); for(i=1;i<=N;i++){ scanf("%d",&a); ord[a]=i; } for(i=1;i<=N;i++){ scanf("%d",&a); w[ord[a]]=i; } for(i=1;i<=N;i++){ add(w[i]); Res=Res+w[i]-Sum(w[i]); } printf("%lld\n",Res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...