Created
January 19, 2017 15:45
-
-
Save KhaledElshamy/5481ebcda63a5312a85cc5a692a2bd13 to your computer and use it in GitHub Desktop.
B. Effective Approach-codeforces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // working.cpp by Bill Weinman <http://bw.org/> | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| int main() { | |
| int n, a, index1[100001]; | |
| cin>>n; | |
| for (int i = 1; i <= n; ++i) | |
| { | |
| cin>>a; | |
| index1[a] = i; | |
| } | |
| int m, b; | |
| cin>>m; | |
| long long Vasya(0), Petya(0); | |
| while (m--) | |
| { | |
| cin>>b; | |
| Vasya += index1[b]; | |
| Petya += (n + 1 - index1[b]); | |
| } | |
| cout<< Vasya<<" "<<Petya<<endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment