Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- int n, q;
- cin >> n >> q;
- int niza[n];
- for(int i = 0; i < n; i++) {
- cin >> niza[i];
- }
- int queries[q];
- for(int i = 0; i < q; i++) {
- cin >> queries[i];
- }
- vector<int> v(55, -1);
- for(int i = 0; i < n; i++) {
- if(v[niza[i]] == -1) {
- v[niza[i]] = i + 1;
- }
- }
- for(int i = 0; i < q; i++) {
- int x = queries[i];
- cout << v[x] << " ";
- for(int j = 1; j <= 50; j++) {
- if(v[j] < v[x] and v[j] != -1) {
- v[j]++;
- }
- }
- v[x] = 1;
- }
- return 0;
- }
- // 89 145 42 20 4 16 37 58
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement