Submission #48946

#TimeUsernameProblemLanguageResultExecution timeMemory
48946leehosu01공장 (KOI13_factory)C++17
14.20 / 20
1022 ms67112 KiB
#include<bits/stdc++.h> using namespace std; unordered_map<int,int>um; class FW{ vector<int>F; int N; public: FW(int k){F.assign((N=k)+1,0);} void in(int X,int Y){for(;X<=N;X+=X&-X)F[X]+=Y;} int out(int X){int sum=0;for(;X;X-=X&-X)sum+=F[X];return sum;} }; int main() { int N; cin>>N; FW tr(N); vector<int>V(N); for(auto&I:V)cin>>I; for(int i=1;i<=N;i++) { int a; cin>>a; um[a]=i; } long long S=0; for(int i=0;i<N;i++) { S+=i-tr.out(um[V[i]]); tr.in(um[V[i]],1); } printf("%lld",S); }
#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...