Submission #16238

#TimeUsernameProblemLanguageResultExecution timeMemory
16238eaststar공장 (KOI13_factory)C++14
20 / 20
258 ms6944 KiB
#include <cstdio> int a[1000010],bit[500010]; long long int s; int getsum(int k){ int sum=0; while(k){ sum+=bit[k]; k-=k&-k; } return sum; } void update(int k,int e,int v){ while(k<=e){ bit[k]+=v; k+=k&-k; } } int main(){ int i,n,k; scanf("%d",&n); for(i=1;i<=n;++i)scanf("%d",&k),a[k]=i; for(i=1;i<=n;++i){ scanf("%d",&k); update(a[k],n,1); s+=getsum(n)-getsum(a[k]); } printf("%lld",s); return 0; }
#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...