Advertisement
Guest User

Untitled

a guest
Mar 29th, 2021
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cmath>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <array>
  7. #include <set>
  8.  
  9. #define ll long long;
  10.  
  11. using namespace std;
  12.  
  13. ifstream fin ("milkorder.in");
  14. ofstream fout ("milkorder.out");
  15.  
  16. int N, M, K;
  17.  
  18. int main()
  19. {
  20.   fin>>N>>M>>K;
  21.   int order[M];
  22.   int cow[K];
  23.   int position[K];
  24.  
  25.   for(int i = 0; i<M; i++){
  26.     fin>>order[i];
  27.   }
  28.  
  29.   for(int i = 0; i<K; i++){
  30.     fin>>cow[i]>>position[i];
  31.   }
  32.   int ans = 1;
  33.   for(int i = 0; i<K; i++){
  34.     ans++;
  35.     int end_pos = 0;
  36.     for(int j = 0; j<M; j++){
  37.  
  38.       if(order[j]==cow[i]){
  39.         int k;
  40.         for(k = j-1; k>=end_pos; k--){
  41.           ans++;
  42.         }
  43.         end_pos=j+1;
  44.       }
  45.     }
  46.   }
  47.   fout<<ans;
  48.  
  49.   return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement