Saleh127

CF 581b

Jul 27th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9.  
  10. int a[200000]={0},c[200000]={0},d,e,f,i,j,k,l;
  11. cin>>d;
  12. for(i=0;i<d;i++)
  13. {
  14. cin>>a[i];
  15. }
  16. for(i=d-1;i>=0;i--)
  17. {
  18. c[i]=max(c[i+1],a[i+1]);
  19. }
  20. for(i=0;i<d;i++)
  21. {
  22. cout<<max(0,(c[i]-a[i]+1))<<" ";
  23. }
  24. return 0;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment