Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
def trackIndexes(x): global index index += 1 return (x,index) size = input(); index = 0 houses = map(lambda x: trackIndexes(int(x)),raw_input().split()) sortedHouses = sorted(houses,reverse = True); cache ,i= 0,0; while i < size: if houses[i][1] <= sortedHouses[cache][1]: if houses[i][0] < sorte...
PYTHON
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = int(input()) w = list(map(int,input().split())) out = [] out.append(0) ma = w[n-1] for i in range(n-2,-1,-1): if(w[i] < ma): out.append((ma+1) - w[i]) elif(w[i] > ma): out.append(0) ma = w[i] elif(w[i] == ma): out.append(1) for k in range(n-1,-1,-1): print(out[k],...
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> int n; int main() { scanf("%d", &n); int arr[n]; for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); } int brr[n], max = arr[n - 1]; brr[n - 1] = 0; for (int i = n - 2; i >= 0; i--) { if (max < arr[i + 1]) max = arr[i + 1]; if (arr[i] <= max) { brr[i] = max - arr...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, a[222222]; scanf("%d\n", &n); pair<int, int> p; vector<pair<int, int> > v, v1; for (int i = 1; i <= n; i++) { int x; scanf("%d", &x); p.first = x; p.second = 0; v.push_back(p); } reverse(v.begin(), v.end()); int maxi =...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Scanner; public class DevelopingSkill { public static void main(String args[]) throws IOException { @SuppressWarnings("resource") Scanner sc=new Scan...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n=int(input()) l=list(map(int,input().split())) if n==1: print (0) exit() m=[-1]*n maxx=l[-1] m[-2]=maxx for i in range(n-3,-1,-1): maxx=max(maxx,m[i+1],l[i+1]) m[i]=maxx ans=[] # print (m) for i in range(n): if l[i]>m[i]: ans.append(0) else: ans.append((m[i]-l[i]+1)) print (*ans)
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; template <typename T> inline T sqr(T x) { T x_ = (x); return x_ * x_; } template <typename T> inline T qbr(T x) { T x_ = (x); return x_ * x_ * x_; } template <typename T> inline int sign(T x) { T x_ = (x); return ((x_ > T(0)) - (x_ < T(0))); } template <typename...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
input() n, result = [int(x) for x in input().split()], [] max = -1 for i in range(len(n) - 1, -1, -1): if n[i] <= max: result.append(max - n[i] + 1) else: max = n[i] result.append(0) for i in range(len(result) - 1, -1, -1): print(result[i], end = ' ') print()
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = int(input()) h = map(int, input().split()[::-1]) m_h = 0 res = [] for h in h: if m_h < h: res.append('0') m_h = h else: res.append(str(m_h - h + 1)) print(" ".join(res[::-1]))
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> int arr[100000] = {0}, arr2[100000] = {0}; int main() { int i, n, max; while (~scanf("%d", &n)) { memset(arr, 0, sizeof(arr)); memset(arr2, 0, sizeof(arr2)); for (i = 0; i < n; i++) scanf("%d", &arr[i]); max = arr[n - 1]; for (i = n - 1; i >= 0; i--) { if (i == n -...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, i, mx = 0, mil, l, limit; scanf("%d", &n); int ara[n], ara2[n]; for (i = 0; i < n; i++) scanf("%d", &ara[i]); for (l = n - 1; l >= 0; l--) { if (ara[l] > mx) { mx = ara[l]; ara2[l] = 0; } else { mil = mx + 1 - ara[l]; ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 100; int a[MAX], ma, ans[MAX]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = n - 1; i >= 0; i--) ans[i] = max(0, ma - a[i] + 1), ma = max(ma, a[i]); for (int i = 0; i < n; i++) cout << ans[i] << " "; ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = int(input()) h = list(map(int, input().split())) mx = h[-1] mh = [] for i in range(n-1, -1, -1): if mx < h[i]: mx = h[i] mh.append(mx) mh = list(reversed(mh)) for i in range(n): res = 0 if i+1 < n and mh[i] == mh[i+1]: res = mh[i]-h[i]+1 print(res, end=' ')
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = int(input()) h = list(map(int, input().split())) max_height = 0 diff = n * [0] for i in range(n).__reversed__(): if h[i] > max_height: max_height = h[i] diff[i] = 0 else: diff[i] = max_height - h[i] + 1 print(*diff)
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = int(input()) a = list(map(int, input().split())) add = [0]*n m = a[n-1] for i in range(n-2, -1, -1): if a[i] > m: add[i] = 0 m = a[i] else: add[i] = m - a[i] + 1 print(*add)
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
number = raw_input() houses = reversed(raw_input().split()) highest = 0 luxury = [] for house in houses: if int(house) > highest: highest = int(house) luxury.append(0) else: luxury.append( highest - int(house) + 1 ) for aaa in reversed(luxury): print aaa,
PYTHON
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.*; import java.io.*; import java.math.*; public class Main1 { static class Reader { private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} public int read() {if (n...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException {...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.awt.Point; import java.io.*; import java.lang.Integer; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; import java.util.ArrayDeque; import static java.lang.Math.*; public class Main { final boolean ONLINE_JUDGE = !new File("input.txt").exists(); BufferedReader in;...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; const int mod = 1000000007; const double eps = 0.0000000001; void solution() { int n; cin >> n; vector<int> a(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } vector<int> dp(n + 1, 0); dp[n] = a[n]; for (int i = n - 1; i ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import itertools n = int(input()) h = [int(x) for x in input().split()] + [0] max_tail = list(itertools.accumulate(reversed(h), max)) max_tail.pop() max_tail.reverse() for i in range(n): print(max(max_tail[i] - h[i] + 1, 0), end = ' ')
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = int(input()) nums = [int(i) for i in input().split()] floorstoadd = [] largesttoright = nums[-1] for i in range(len(nums)-2, -1, -1): if nums[i] <= largesttoright: newone = str(largesttoright - nums[i] + 1) floorstoadd.append(newone[::-1]) else: largesttoright = nums[i] floo...
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const double PI = acos(-1.0); template <class T> inline T _abs(T n) { return ((n) < 0 ? -(n) : (n)); } template <class T> inline T _max(T a, T b) { return (!((a) < (b)) ? (a) : (b)); } template <class T> inline T _min(T a, T b) { return (((a) ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
def luxhouse(n, h): r = [0] * n m = h[-1] n -= 2 while n >= 0: if m >= h[n]: r[n] = m - h[n] + 1 else: m = h[n] n -= 1 return r n = int(input()) h = raw_input().split(' ') for i in range(len(h)): h[i] = int(h[i]) for i in luxhouse(n, h): p...
PYTHON
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
from collections import deque n = input() a = map(int, raw_input().split()) maxA = 0 res = deque() for i in range(len(a)-1, -1, -1): diff = maxA - a[i] if diff < 0: res.appendleft(str(0)) else: res.appendleft(str(diff + 1)) if a[i] > maxA: maxA = a[i] print ' '.join(res)
PYTHON
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import math import itertools import collections def getdict(n): d = {} if type(n) is list: for i in n: if i in d: d[i] += 1 else: d[i] = 1 else: for i in range(n): t = ii() if t in d: d[t] += 1 ...
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; long long int mas[100001], ans[100001]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> mas[i]; } long long int ma = 0; for (int i = n - 1; i >= 0; i--) { if (mas[i] > ma) { ans[i] = 0; ma = mas[i]; } else { if (m...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.IOException; import java.util.InputMismatchException; import java.util.TreeSet; //package PACKAGE_NAME; /** * Created by gaponec on 28.09.15. */ public class B322 { public static void main(String[] args) { MyScanner sc = new MyScanner(); int n = sc.nextInt(); int[] arr =...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = input() houses = map(int, raw_input().split()) result = [0] * n last = len(houses) - 2 maxHeight = houses[-1] while last >= 0: if houses[last] <= maxHeight: result[last] = maxHeight - houses[last] + 1 maxHeight = max(maxHeight, houses[last]) last -= 1 print ' '.join(map(str, result))
PYTHON
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int x, c = 0, w; cin >> x; int a[x], b[x]; for (int i = 0; i < x; i++) cin >> a[i]; w = a[x - 1]; for (int i = x - 1; i >= 0; i--) { if (a[i] == w) b[i] = 1; if (a[i] > w) { w = a[i]; b[i] = 0; } if (a[i] < w) b[i] = abs(...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n=int(input()) a=list(map(int,input().split())) ans=[0]*n mx=a[n-1] for i in range(n-2,-1,-1): ans[i]=max(0,mx-a[i]+1) if a[i]>mx: mx=a[i] print(*ans)
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.*; import java.util.*; public class LuxuriousHouses { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == nul...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
# http://codeforces.com/problemset/problem/581/B def calculate(numbers): numbers = map(int, numbers.split()) result = [] current = 0 for i in numbers[::-1]: if i <= current: result.append(current - i + 1) else: result.append(0) current = i retu...
PYTHON
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int n, h[maxn], ans[maxn]; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) cin >> h[i]; int _max = h[n]; for (int i = n - 1; i >= 1; i--) { if (h[i] > _max) ans[i] = 0; else ans[i] = _ma...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> int n, i, mx, h[100005], t[100005]; int main() { scanf("%d", &n); for (i = 1; i <= n; i++) scanf("%d", &h[i]); for (i = n; i >= 1; i--) if (h[i] > mx) mx = h[i]; else t[i] = mx - h[i] + 1; for (i = 1; i <= n; i++) printf("%d ", t[i]); return 0; }
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.*; import java.io.*; import java.math.*; import java.text.*; public class Main { static FastScanner in = new FastScanner(System.in); static StringBuilder sb = new StringBuilder(); static DecimalFormat df = new DecimalFormat(); public static void main(String[] args) { df.setMaximumFractio...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.BufferedOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.*; public class test { public static void main (String[] args) throws IOException { Scanner sc = new Scanner(System.in); OutputStream out = new BufferedOutputStream ( System.out ); int n = sc.nextInt(...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; long long a[100010], b[100010]; int main() { long long n, x, i = 0; scanf("%lld", &n); long long j = n - 1; while (i < n) { scanf("%lld", &a[i]); i++; } b[j] = 0; j--; x = 0; long long total = x + a[n - 1]; for (i = n - 2; i >= 0; i--) { if (...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.*; public class BF { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); long a[]=new long[n]; long r[]=new long[n]; for(int i=0;i<n;i++) a[i]=sc.nextLong(); long m=0; for(int i=n-1;i>=0;i--) { if(a[i]<=m) r[i]=m-a[i]+1; m=Math.max(m,a[i]); } for(int i=0;i<n;...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int arr[n]; for (int i = 0; i < n; ++i) { cin >> arr[i]; } int mx = -100; vector<int> ans; for (int i = n - 1; i > -1; --i) { if (arr[i] < mx) ans.emplace_back(mx - arr[...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { // TODO Auto-generated method stub BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import sys n = int(input()) a = list(map(int, sys.stdin.readline().split())) b = [0]*n for i in range(n-2,-1,-1): b[i] = max(a[i+1],b[i+1]) c = [max(b[i]+1-a[i],0) for i in range(n)] c[-1] = 0 print(' '.join([str(i) for i in c]))
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int a[100005]; stack<int> s; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; ++i) scanf("%d", a + i); int maxx = -1; for (int i = n - 1; i >= 0; --i) { if (maxx >= a[i]) s.push(maxx + 1 - a[i]); else s.push(0); maxx = max(maxx, ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = int(input()) a = list(map(int, input().split())) f = [0] * (n + 1) r = [0] * (n + 1) for i in range(n - 1, -1, -1): f[i] = f[i + 1] if f[i] >= a[i]: r[i] = f[i] - a[i] + 1 f[i] = max(f[i], a[i]) for i in range(n): print(r[i], end=" ")
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.*; import java.util.*; public class Main { private final static InputReader ir = new InputReader(System.in); private final static OutputWriter ow = new OutputWriter(System.out); private final static int INF = Integer.MAX_VALUE; private final static int NINF = Integer.MIN_VALUE; priva...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
from collections import deque input() A, max_h = deque(), 0 for h in reversed(list(map(int, input().split()))): if h > max_h: max_h = h A.appendleft(0) else: A.appendleft(max_h - h + 1) print(*A)
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int ara[100]; int main() { int n; cin >> n; int ara[n]; int i; for (i = 0; i < n; i++) { cin >> ara[i]; } int max = -1; for (i = n - 1; i >= 0; i--) { if (ara[i] > max) { max = ara[i]; ara[i] = 0; } else { ara[i] = max - ara[i] ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n=int(input()) h=list(map(int,input().split())) h.reverse() s=[] m=0 for i in h: if i>m: m=i a=0 elif m >=i: a=(m-i)+1 s+=[str(a)] s.reverse() print(' '.join(s))
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.*; public class test { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; int[] anss = new int[n]; int[] dh = new int[n]; for (int i = 0; i < n; i++) arr[i] = sc.nextInt(); dh[n-1] = 0; anss[n-1]=0; String...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
raw_input() h = map(int, raw_input().split(' ')) maxi = [] temp = h[len(h) - 1] c_temp = 0 for i in xrange(len(h) - 1, -1, -1): if temp != max(temp, h[i]): c_temp = 0 temp = max(temp, h[i]) if temp == h[i]: c_temp += 1 maxi.append((temp, c_temp)) # print temp, c_temp # print maxi for (i, j) in zip(xrange(len...
PYTHON
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { long long r; while (b != 0) { r = a % b; a = b; b = r; } return a; } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } long long n, A[100005], tmp, dem, Ma[100005]; int main() { ios_base::sy...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.io.Writer; impo...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.Scanner; public class Ma { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] ArrIn= new int[N]; int[] ArrOut= new int[N]; int i=0; for (int k=0; k<N; k++) { ArrIn[k] = sc.nextInt(); ...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.*; import java.util.StringTokenizer; /** * Created by Alvin on 5/20/2016. */ public class Codeforces_round_322_div_2_LuxuriousHouses { public static void main(String[] args) { FScanner input = new FScanner(); out = new PrintWriter(new BufferedOutputStream(System.out), true); ...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int max; max = a[n - 1]; int h[n]; h[n - 1] = 0; for (int i = n - 2; i >= 0; i--) { if (max < a[i]) { h[i] = 0; } else { h[i] = max - a[i] + 1; ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Stack; public class domik { public static void main(String[] args) throws IOException { Stack stek=new Stack(); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String s = r...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> nums; for (int i = 0; i < n; i++) { int nxt; cin >> nxt; nums.push_back(nxt); } int suffmax[100000]; suffmax[n - 1] = -999999; for (int i = n - 2; i >= 0; i--) { suffmax[i] = max(suffmax[i + 1], nums[...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class LuxuriousHouses { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n ...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int house; cin >> house; int *floor = (int *)malloc(sizeof(int) * house); int *added = (int *)malloc(sizeof(int) * house); fill(added, added + house, 0); for (int i = 0; i < house; i++) cin >> floor[i]; int max = floor[house - 1]; for (int i = h...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n=int(input()) arr=list(map(int,input().split())) temp=[None]*n m=0 last=0 for i in range(n): if last>m: m=last last=arr[n-1-i] temp[n-1-i]=m for i in range(len(arr)): if arr[i]<temp[i]+1: print(temp[i]+1-arr[i],end=' ') else: print(0,end=' ')
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.*; import java.lang.reflect.Array; import java.net.Inet4Address; import java.nio.ByteBuffer; import java.util.*; public class test { int max = 0; long t[]; boolean visited[]; ArrayList<Integer> queue = new ArrayList<>(); public static void main(String args[]) throws IOException { ...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.*; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt();long max=0; int[] a = new int[n]; long[] b = new long[n]; for(int i=0;i<n;i++) { a[i]=sc.nextInt(); } fo...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
input() nums = [int(t) for t in input().split()] max_ = nums[-1] - 1 for i in range(len(nums) - 1, -1, -1): newVal = nums[i] if nums[i] > max_ else max_ + 1 max_ = max(max_, nums[i]) nums[i] = newVal - nums[i] # print(nums) for i, k in enumerate(nums): print(k, end=' ' if i != (len(nums) - 1) else '\n...
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = input() buildings = input().split(' ') m = 0 result = [] for building in buildings[::-1]: b = int(building) x = m - b if x < 0: result.append('0') m = b else: result.append(str(x + 1)) print(' '.join(result[::-1]))
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = sc.nextInt(); int max = a[n-1]; int[] ans = new int[n]; ans[n-1] = 0; for(int ...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; long long a[200000], b[200000], n; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = n; i >= 1; i--) b[i] = max(a[i], b[i + 1]); for (int i = 1; i <= n; i++) if (b[i + 1] >= a[i]) cout << b[i + 1] - a[i] + 1 << " "; else ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n=input() a=map(int,raw_input().split()) h=0 for i in range(n-1,-1,-1): x=max(0,h+1-a[i]) h=max(h,a[i]) a[i]=x for x in a: print x,
PYTHON
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int n; int h[100001]; int r[100001]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", h + i); int maxis = 0; for (int i = n - 1; i >= 0; i--) { int k = maxis - h[i] + 1; if (k >= 0) r[i] = k; else r[i] = 0; maxis = ma...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; bool flag; void fast() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } string con(long long od) { stringstream st; st << od; string pr; st >> pr; return pr; } int main() { fast(); int n, mn = (INT_MIN); cin >> n; vector<int> v(n, 0); vector<i...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = int(input()) a = list(map(int,input().split())) L = [0] * n mx = 0 for i in range(n-1, -1, -1): if a[i] > mx: L[i] = 0 else: L[i] = mx + 1 - a[i] mx = max(mx, a[i]) print(*L)
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = int(input()) h = list(map(int, input().split())) h.reverse() ans = [0] m = h[0] for i in range(1, n): if h[i] > m: ans.append(0) m = h[i] else: ans.append(m-h[i] + 1) ans.reverse() print(*ans, sep=' ')
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
N = int(raw_input()) A = map(int , raw_input().split()) l = len(A) B = [0] max_to_right = A[-1] for i in range(2,len(A)+1): max_to_right = max(max_to_right, A[-i+1]) B.append(max(0, max_to_right-A[-i]+1)) B.reverse() for i in B: print i,
PYTHON
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = int(input()) mat = list(map(int,input().split()))[::-1] rmnd = 0 sat = [] for i in mat: if rmnd >= i: sat.append(rmnd - i + 1) else: sat.append(0) rmnd = i print(*sat[::-1])
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
_ = input() a = [int(x) for x in input().split()] mx = 0 ans = [] for x in reversed(a): if x > mx: ans.append(0) mx = x else: ans.append(mx - x + 1) ans = reversed(ans) print(' '.join(str(x) for x in ans))
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
def main(): raw_input() L = [ int(i) for i in raw_input().split(" ") ] res = [] maxi = 0 for i in range(len(L)-1,-1,-1): res.append( str( max(0,maxi+1-L[i])) ) maxi = max(L[i],maxi) res.reverse() print " ".join(res) main()
PYTHON
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = input() h = map(int, raw_input().split()) + [0] goal = [0 for i in xrange(n+1)] for i in xrange(n-1, -1, -1): goal[i] = max(goal[i+1], h[i+1]+1) print " ".join([str(max(0, goal[i] - h[i])) for i in xrange(n)])
PYTHON
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
mod = 10 ** 9 + 7 ii = lambda : int(input()) si = lambda : input() dgl = lambda : list(map(int, input())) f = lambda : map(int, input().split()) il = lambda : list(map(int, input().split())) ls = lambda : list(input()) n=ii() l=il() l1=[0]*n mx=0 for i in range(n-1, -1, -1): if l[i]<=mx: l1[i]=mx-l[i]+1 ...
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> int main(int argc, char const *argv[]) { int n, i, max; scanf("%d", &n); int a[n]; int r[n]; for (i = 0; i < n; i++) scanf("%d", &a[i]); r[n - 1] = 0; max = a[n - 1]; for (i = n - 2; i >= 0; i--) { if (a[i] <= max) { r[i] = max - a[i] + 1; } else { r[i] = 0; ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
""" Codeforces Round #322 (Div. 2) Problem 581 B. Luxurious Houses @author yamaton @date 2015-10-06 """ import itertools as it import functools import operator import collections import math import sys def solve(xs): max_height = 0 result = [] for x in reversed(xs): if x > max_height: ...
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int main() { int arr[123456]; int maxx[123456]; int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); } maxx[n] = 0; for (int i = n - 1; i >= 0; i--) { maxx[i] = max(maxx[i + 1], arr[i]); } for (int ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int n; cin >> n; vector<long long int> vec(n), ans(n); for (int i = 0; n > i; i++) { cin >> vec[i]; } long long int maxi = vec[n - 1], sifir = 0; ans[n - 1] = 0; for (int i = n - 2; i >= 0; i--) { ans[i] = ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, b, mx = 0; cin >> n; int a[n + 1]; vector<int> t; for (int k = 1; k <= n; k++) cin >> a[k]; for (int k = n; k >= 1; k--) { t.push_back(max(0, mx - a[k] + 1)); mx = max(a[k], mx); } for (int k = t.size() - 1; k >= 0; k--) { cou...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, maxFloor = 0; cin >> n; int h[n]; int ans[n]; for (int i = 0; i < n; i++) { cin >> h[i]; } maxFloor = h[n - 1]; ans[n - 1] = 0; for (int i = n - 2; i >= 0; i--) { if (maxFloor < h[i]) { maxFloor = h[i]; ans[i] = 0; ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
//package CodeForces.Round322; import java.util.Scanner; /** * Created by Ilya Sergeev on 28.09.2015. */ public class Belitn { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] mass = new int[n]; for (int i = 0; i < n; i++) ...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; long long a[200000], b[200000]; int main() { ios_base::sync_with_stdio(0); long long n, mx = 0, i, kol = 1; cin >> n; for (i = 1; i <= n; i++) cin >> a[i]; for (i = n; i >= 1; i--) { b[kol] = max(0ll, mx - a[i] + 1); mx = max(mx, a[i]); kol++; } fo...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int t, a[100005], c[100005]; cin >> t; for (int x = 0; x < t; x++) cin >> a[x]; c[t - 1] = 0; int flag = a[t - 1]; for (int x = t - 2; x >= 0; x--) { a[x] > flag ? c[x] = 0 : c[x] = flag - a[x] + 1; flag = max(flag, a[x]); } for (int x =...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.*; import java.util.StringTokenizer; public class Luxhouses { public static void main(String arg[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] stra; StringBuilder sb=new StringBuilder(); int[] arr; ...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; void maxe(long long int *array, long long int begin, long long int end, long long int *max, long long int *index) { long long int i, maxi = -9; for (i = begin; i < end; i++) { if (array[i] >= maxi) { maxi = array[i]; *index = i; } } *ma...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long n, _max; vector<long long> h, lux; cin >> n; h.resize(n); lux.resize(n); for (long long i = 0; i < n; i++) cin >> h[i]; lux[n - 1] = 0; _max = n - 1; for (long long i = n - 2; i >= 0; i--) { if (h[i] <= h[_max]) lux[i] = h[...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; const double pi = 2 * acos(0.0); const int OO = 0x3f3f3f3f; const int N = 1e5 + 5; int arr[N], n; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; i++) cin >> arr[i]; int mx = -1; vector<int> v; for (int i = n -...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n=int(input()) l=list(map(int,input().split())) maxh=0 a=[] for i in range(n-1,-1,-1): a.append((max(0,maxh+1-l[i]))) if l[i]>maxh: maxh=l[i] for i in range(n-1,-1,-1): print(a[i],end=" ")
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n= int(input()) a= [int(i) for i in input().split()] pref= [0]*n from collections import defaultdict d = defaultdict(int) pref[-1] = a[-1] d[pref[-1]]=n-1 for i in range(n-2,-1,-1): pref[i] = max(pref[i+1],a[i]) if d[pref[i]]==0: d[pref[i]]=i out = [0]*n for i in range(n): if a[i]==pref[i] and...
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, i, arr[1 << 18]; cin >> n; for (i = 0; i < n; i++) cin >> arr[i]; vector<int> v1; int max1 = -1; for (i = n - 1; i >= 0; i--) { if (max1 == -1 || max1 < arr[i]) v1.push_back(0); else v1.push_back(max1 - arr[i] + 1); ma...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, c = 0; int zero = 0; vector<int> v; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } for (int i = n - 1; i >= 0; i--) { if (arr[i] > c) { v.push_back(zero); c = arr[i]; } else v.push_back(...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int t, n, i, j, ma; cin >> n; int arr[n], b[n]; for (i = 0; i < n; i++) { cin >> arr[i]; } ma = arr[n - 1]; b[n - 1] = 0; for (i = n - 2; i >= 0; i--) { if (arr[i] <= ma) { b[i] = (ma - arr[i]) + 1; } else { b[i] = 0; ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, i, j; int max = INT_MIN; cin >> n; int a[n]; int b[n]; for (i = 0; i < n; i++) { cin >> a[i]; } for (j = n - 1; j >= 0; j--) { if (a[j] <= max) { b[j] = max + 1 - a[j]; ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> const int MX = 100005; using namespace std; int main() { int n; cin >> n; long long int ar[n + 5]; long long int maxi[n + 5]; for (int i = 0; i <= n - 1; i++) cin >> ar[i]; maxi[n - 1] = ar[n - 1]; for (int i = n - 2; i >= 0; i--) { maxi[i] = ((ar[i]) > (maxi[i + 1]) ? (ar[i])...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.Scanner; public class LuxuriousHouses { static int K; static int[] intarray; static Scanner scan; static int[] results; static int max; public static void main(String[] args) { scan = new Scanner(System.in); K = scan.nextInt(); intarray = new int[K]; results = new int[K]; results[K - ...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.*; import java.lang.reflect.Array; import java.util.*; public class CodeForces { public static void main(String[] args)throws IOException { //MyScanner sc = new MyScanner(new FileReader("input.txt")); //PrintWriter out = new PrintWriter("output.txt"); PrintWriter out = new Pr...
JAVA