Ankit_132

C

Oct 1st, 2023
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll     long long
  6.  
  7. int main()
  8. {
  9.     int n, m;
  10.     cin>>n>>m;
  11.  
  12.     vector<int> a(m);
  13.     for(auto &e: a)     cin>>e;
  14.  
  15.     map<int, int> mp;
  16.     for(auto e: a)
  17.         mp[e] = 1;
  18.  
  19.     int x = 0;
  20.     vector<int> ans(n);
  21.  
  22.     for(int i=n; i>=1; i--)
  23.     {
  24.         if(mp[i])       x = 0;
  25.  
  26.         ans[i-1] = x;
  27.         x++;
  28.     }
  29.  
  30.     for(auto e: ans)        cout<<e<<"\n";
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment