Submission #7587

#TimeUsernameProblemLanguageResultExecution timeMemory
7587jihoon공장 (KOI13_factory)C++98
20 / 20
256 ms12996 KiB
#include<cstdio> int n; int bit[1048577]; int num[1000001]; int idx[1000001]; void update(int idx){ while(idx<=1048576){ bit[idx]++; idx+=(idx & -idx); } } int sum(int idx){ int hap=0; while(idx>0){ hap+=bit[idx]; idx-=(idx & -idx); } return hap; } int main(){ int i,ia; long long int dap=0; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&ia); num[ia]=i+1; } for(i=0;i<n;i++){ scanf("%d",&ia); dap+=i-sum(num[ia]); update(num[ia]); } printf("%lld",dap); }
#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...