Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- int main()
- {
- int n, m;
- cin>>n>>m;
- vector<int> a(m);
- for(auto &e: a) cin>>e;
- map<int, int> mp;
- for(auto e: a)
- mp[e] = 1;
- int x = 0;
- vector<int> ans(n);
- for(int i=n; i>=1; i--)
- {
- if(mp[i]) x = 0;
- ans[i-1] = x;
- x++;
- }
- for(auto e: ans) cout<<e<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment