Advertisement
bappi2097

A - Jumping Buildings

Aug 19th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. void inOut()
  4. {
  5.     ios_base::sync_with_stdio(false);
  6.     cin.tie(NULL);
  7.     #ifndef ONLINE_JUDGE
  8.     freopen("input.txt","r",stdin);
  9.     #endif // ONLINE_JUDGE
  10. }
  11. int main()
  12. {
  13.     inOut();
  14.     int n;
  15.     cin>>n;
  16.     int ar[n];
  17.     for(int i=0;i<n;i++)cin>>ar[i];
  18.     for(int i=0;i<n;i++)
  19.     {
  20.         int mini=min(i+1+ar[i],n),cnt=0;
  21.         for(int j=i+1;j<mini;j++)
  22.         {
  23.             if(ar[i]>=ar[j])cnt++;
  24.             else break;
  25.         }
  26.         cout<<cnt<<' ';
  27.     }
  28.     cout<<endl;
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement