| 3 | using namespace std; |
| 4 | |
| 5 | int main(){ |
| 6 | int n, max=0; |
| 7 | cin >> n; //number of houses in the capital of Berland |
| 8 | int a[n], b[n]; |
| 9 | |
| 10 | for(int i=0; i<n; i++){ |
| 11 | cin >> a[i]; //number of floors in the i-th house |
| 12 | } |
| 13 | |
| 14 | b[n-1]=0; |
| 15 | max=a[n-1]; //consider that initially the largest house is the one on the right most |
| 16 | for(int i=n-2; i>=0; i--){ //for from right to left |
| 17 | if(a[i]<=max) b[i]=max-a[i]+1; //if the current house is smaller than the one considered to be bigger so far |
| 18 | else b[i]=0, max=a[i]; //if the current house is bigger than all the previous ones |
| 19 | } |
| 20 | |
| 21 | for(int i=0; i<n; i++){ |
| 22 | cout << b[i] << " "; |
| 23 | } |
| 24 | return 0; |
| 25 | } |
nothing calls this directly
no outgoing calls
no test coverage detected