581B Codeforces - Luxurious Houses
Solution in C++
#include <bits/stdc++.h>
using namespace std;
int n,m,mx,t;
map<int,int> all,nn,tax;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n;
int nn[n];
for(int i=0;i<n;i++)cin>>t,nn[i]=t;
all[n-1]=nn[n-1];
for(int i=n-2;i>=0;i--)
{
if(nn[i]<=all[i+1])tax[i]=1;
all[i]=max(all[i+1],nn[i]);
}
for(int i=0;i<n;i++)cout<<all[i]-nn[i]+tax[i]<<" ";
return 0;
}
Ycrimepcomp-ga Shelley Jodon download
ردحذفvexeddibo