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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class LuxoriousHouses { public static void main(String[] args) throws IOException { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int []max=...
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> int main() { int n, i, s[200000], t[200000], j, x = 1, y, max = 0; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &s[i]); } max = s[n]; t[n] = 0; for (i = n - 1; i >= 1; i--) { if (s[i] > max) { t[i] = 0; max = s[i]; } else { t[i] = max + 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
#include <bits/stdc++.h> using namespace std; long long a[100009]; long long max2[100009]; bool isnew[100009]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } max2[n - 1] = a[n - 1]; isnew[n - 1] = true; for (int i = n - 2; i >= 0; i--) { if (a[i] > max2[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
n=int(raw_input('')) s=raw_input('') a=s.split(" ") arr=[] for i in range(n): arr.append(int(a[i])) max=-1 b=[] for i in range(n): k=arr[n-i-1] if k>max: b.append(0) max=k elif k==max: b.append(1) else: b.append(max-k+1) b=b[::-1] print ' '.join(map(str,b))
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.HashSet; import java.util.Scanner; public class codeforcesB { public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); long[] h = new long[n]; for (int i = 0; i<n; i++) h[i] = in.nextLong(); long max = h[n-1]; HashSet<Integer> e = new HashSet<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
n=int(input()) a=list(map(int,input().split())) ans=[0]*n curr_max=-1 for i in range(n-1,-1,-1): if a[i]>curr_max: ans[i]=0 curr_max=a[i] else: ans[i]=curr_max-a[i]+1 for i in range(n): print(ans[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
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n + 1]; int b[n + 1]; for (int i = 0; i < n; i++) cin >> a[i]; int mx = INT_MIN; for (int i = n - 2; i >= 0; i--) { mx = max(mx, a[i + 1]); b[i] = mx; } for (int i = 0; i < n - 1; i++) { cout << max(b[i] - 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
#include <bits/stdc++.h> using namespace std; int main() { long long int n, max1 = 0; cin >> n; long long int a[n]; long long int b[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } b[n - 1] = 0; max1 = a[n - 1]; for (int i = n - 2; i >= 0; i--) { if (a[i] > max1) { b[i] = 0; max1 =...
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, max = 0, a[100005], b[100005]; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &a[i]); } max = a[n - 1]; b[n - 1] = 0; for (i = n - 2; i >= 0; i--) { if (a[i] <= max) { b[i] = max - a[i] + 1; } else { b[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 n; vector<int> h, s; int main() { ios_base::sync_with_stdio(false); cin >> n; h.resize(n); for (int i = 0; i < n; ++i) cin >> h[i]; s = h; for (int i = (int)s.size() - 2; i >= 0; --i) s[i] = max(s[i], s[i + 1]); for (int i = 0; i < (int)s.size(); ++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() { long long int n, a; cin >> n; vector<long long int> vec(n), copie; for (long long int i(0); i < n; i++) { cin >> a; vec.push_back(a); } reverse(begin(vec), end(vec)); copie.push_back(0); int maxi = vec[0]; for (long long int i(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
n = input() buildings = input().split(' ') m = 0 lenght = len(buildings) - 1 result = [] for i in range(lenght, -1, -1): b = int(buildings[i]) x = m - b if x < 0: result.append('0') m = b else: result.append(str(x + 1)) print(' '.join([result[i] for i in range(lenght, -1, -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
n = input() buildings = list(map(int, input().split(' '))) m = 0 result = [] for b in buildings[::-1]: x = m - b if x < 0: result.append(0) m = b else: result.append(x + 1) print(' '.join(map(str, 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
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int MaxN = int(2e5) + 256; const int MOD = int(1e9) + 7; template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } inline bool Palindrome(const string& s) { return equal(s.begin(), s.end(), s.rbegin()); } int s[MaxN], ...
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
from collections import Counter n=int(input()) a=[int(x) for x in input().split()] mx=-1 ans=[0]*n for i in reversed(range(n)): ans[i]=max(0,mx+1-a[i]) mx=max(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
#include <bits/stdc++.h> using namespace std; int n, a[100001]; int m[100002]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; m[n] = 0; for (int i = n - 1; i >= 0; i--) m[i] = max(a[i], m[i + 1]); for (int i = 0; i < n; i++) cout << max(0, m[i + 1] - a[i] + 1) << (i == n - 1 ? '\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(raw_input()) a = [int(x) for x in raw_input().split()] a.append(0) c = 0 b = [] for i in xrange(n): j = a[n - i - 1] c = max(c , a[n - i]) if j > c: k = 0 else: k = c + 1 - j b.append(k) for i in xrange(n): print b[n - 1 - 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()) house = list(map(int,input().split())) house.reverse() final = [] largestVal = 0 for i in house: if i > largestVal: final.append("0") else: final.append(f"{largestVal - i + 1}") largestVal = max([largestVal,i]) final.reverse() print(' '.join(final))
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()) l=[int(i) for i in input().split()] b = n*[0] maxh = l[n-1] for i in range(n-2,-1,-1): b[i] = max(0,maxh+1-l[i]) maxh = max(maxh,l[i]) print(*b)
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; set<long long> st; long long b[200007], a[200007], t, r, x1, l, y2, x2, y4, n, i, k, ma, p, j, mi, p1, p2, p3, p4, l1, l2, l3, l4, c; string s, s1, s2, s3; char ch; int main() { cin >> n; for (i = 1; i <= n; i++) cin >> a[i]; ma = a[n]; b[n] = 0; for (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 n, a[100005], maxi, b[100005]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } maxi = a[n - 1]; for (int i = n - 2; i >= 0; i--) { if (a[i] > maxi) { maxi = a[i]; b[i] = 0; } else b[i] = maxi + 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.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
import java.io.*; import java.math.*; import java.util.*; /** * Created by Sai on 2015/9/28. */ public class B { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); 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; const int inf = 1e9 + 2; const double pi = acos(-1.0); const int N = 300010; int n, a[N], suf[N], res[N]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); suf[n] = a[n]; for (int i = n - 1; i >= 1; i--) suf[i] = max(suf[i + 1], a[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; void solve() { long long int n; cin >> n; vector<long long int> v(n); vector<long long int> v1(n); for (long long int i = 0; i < n; i++) cin >> v[i]; long long int max = v[n - 1]; long long int cnt = 0; for (long long int i = n - 1; i > -1; i--) { if (v[...
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 codeforces581B { public static void main(String[] args) { Scanner s=new Scanner(System.in); StringBuilder sb = new StringBuilder(); int n=s.nextInt(),i; int[] a = new int[n]; int[] m = new int[n]; for(i=0;i<n;i++) a[i]=s.nextInt(); m[n-1]=a[n-1]; for(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() { int n, a[100000], i, m[100000]; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; m[n - 1] = a[n - 1]; for (i = n - 2; i > 0; i--) { if (a[i] > m[i + 1]) m[i] = a[i]; else m[i] = m[i + 1]; } for (i = 0; i < n - 1; i++) { if (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
#include <bits/stdc++.h> using namespace std; int x[100009], a[100009]; int main() { int n, mx; cin >> n; for (int i = 0; i < n; ++i) cin >> x[i]; a[n - 1] = 0; mx = x[n - 1]; for (int i = n - 2; i >= 0; --i) { if (mx == x[i]) { a[i] = 1; } else if (mx < x[i]) { a[i] = 0; mx = x[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() { long long int n, ar[1000001], i, m; vector<long long int> vec; cin >> n; for (i = 0; i < n; i++) { cin >> ar[i]; } m = ar[n - 1]; for (i = n - 2; i >= 0; i--) { if (ar[i] == m + 1) vec.push_back(0); else if (ar[i] > m) vec....
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; vector<int> vec; vector<int> dp; vector<int> rein; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; vec.push_back(x); } int big = -2; dp.resize(n); rein.resize(n); fill(rein.begin(), rein.end(), 0); for (int j = 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('')) arr=list(map(int,input().split())) max=-1 b=[] for i in range(0,n): p=arr[n-1-i] if p>max: b.append(0) max=p else: b.append(max-p+1) for i in range(0,n): print(b[n-i-1],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
num=int(input()) a=list(map(int,input().split())) b=[0]*num maxx=a[-1] for i in range(num - 2, -1, -1): if a[i] <= maxx: b[i] = maxx - a[i] + 1 else: maxx = a[i] print(*b)
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[101000], g[101000]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = n; i >= 1; i--) g[i] = max(g[i + 1], a[i]); for (int i = 1; i <= n; i++) { if (a[i] > g[i + 1]) printf("0 "); else prin...
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())) max_num=0 res=[0]*n for i in range(n-1,-1,-1): res[i]=max(0,max_num-a[i]+1) max_num=max(max_num,a[i]) print(' '.join(map(str,res)))
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())) + [0] h_max = 0 res = [] for i in range(n, 0, -1): h_max = max(h_max, h[i] + 1) res.append(max(h_max - h[i - 1], 0)) print(" ".join(map(str, 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
import java.util.*; import java.io.*; public class B581 { public static void main(String[] args) throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(System.out); int n = input.nextInt(); int[] a = new int[n]; for(int i = 0; i<n; i++) a[i] = input.nextInt(); int max = a[...
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() a=list(map(int, input().split()))[::-1] x=-1 b=[] for v in a: b+=[max(0,x-v+1)] x=max(x,v) print(*b[::-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
from __future__ import print_function t = int(input()) a = list(map(int , input().split())) b=[] max = a[t-1] i=t-2 while i >= 0: if a[i] <= max: b.append(max-a[i]+1) else: max = a[i] b.append(0) i = i-1 b.insert( 0, "0") i = t-1 while(i>=0): print(b[i] , end = " ") i = 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
import java.util.ArrayList; import java.util.Scanner; public class cf581b { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=in.nextInt(); ArrayList<Integer> houses = new ArrayList<>(); ArrayList<Integer> floors = new ArrayList<>(); 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
n = int(input()) L = list(map(int,input().split())) maxlist = [L[-1] for i in range(n)] for i in range(n-2,-1,-1): maxlist[i] = max(L[i],maxlist[i+1]) M = [None for i in range(n)] for i in range(n): if L[i] == maxlist[i]: if i+1 < n and maxlist[i] == maxlist[i+1]: M[i] = str(1) else:...
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() { ios::sync_with_stdio(false); long long n, i; cin >> n; long long a[n], revMax[n]; for (i = 0; i < n; i++) cin >> a[i]; revMax[n - 1] = a[n - 1]; for (i = n - 2; i >= 0; i--) { revMax[i] = max(revMax[i + 1], a[i]); } for (i = 0; i < n - 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.util.*; public class LuxuriousHouses { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int a[] = new int[n]; for(int j = 0; j < n; ++j){ a[j] = scanner.nextInt(); } int maxi = a[n-1]; int b[] = new int[n]; b[n-1] = ...
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()) a = list([int(x) for x in input().split()]) maxs = a[-1] needed = [0] * n for i in range(n - 2, -1, -1): need = max(0, maxs - a[i] + 1) needed[i] = need maxs = max(maxs, a[i]) print(*needed)
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[100100], h[100100], mx[100100]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { scanf("%d", a + i); } for (int i = n; i >= 1; i--) { mx[i] = max(mx[i + 1], a[i]); } for (int i = 1; i <= n; i++) { if (a[i] > mx[i + 1]) continue; ...
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, s; cin >> n; vector<long long> vc; for (long long i = 0; i < n; i++) { cin >> s; vc.push_back(s); } long long mx = -9999; vector<long long> build; mx = vc[n - 1]; build.push_back(0); for (long long i = n - 2; i >= 0; 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 sys n = int(sys.stdin.next()) floors = map(int, sys.stdin.next().split(' ')) m = 0 s = [] for h in floors[::-1]: s.append('%i' % ((m - h + 1) if (m - h + 1) > 0 else 0)) m = max(h, m) print(' '.join(s[::-1]).strip())
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.*; public class luxurioushouses { public static void main(String args[]) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int a[]=new int[n]; int b[]=new int[n]; int i,pos=0,s=0,max=0; for(i=0;i<n;i++) a[i]=in.nextInt(); /*d...
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, i, j; long long int a[100003], b[100003]; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } b[n - 1] = 0; long long int max = a[n - 1]; for (j = n - 2; j >= 0; j--) { if (a[j] > max) { max = a[j]; b[j] = 0; } 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Stack; import java.util.StringTokenizer; public class LuxHouse { public static void main(String[] args) { Input...
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.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class cf { public static void main(String[] args) throws Exception { Scanner in=new Scanner(System.in); int n=in.nextInt(); 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
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
n = int(input()) #n, m = map(int, input().split()) #s = input() c = list(map(int, input().split())) a = [0] * n l = c[-1] for i in range(n - 2, -1, -1): if c[i] > l: l = c[i] else: a[i] = l - c[i] + 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
def GetLuxHts(hts): heights = [] for i in hts: heights.append(int(i)) lux_hts_revrsd = '' lux_hts = '' max_height = heights[len(hts)-1] for i in range(len(hts)-1,-1,-1): if heights[i] <= max_height and i!=len(hts)-1: diff = max_height - heights[i] + 1 #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
import java.io.*; import java.util.*; public class b1 { public static void main(String[] args) throws FileNotFoundException { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int h[] = new int[n]; for (int i = 0; i < n; i++) { h[i] = in.ne...
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()) array = list(map(int, input().split())) maxH = -1 luxury = list() for i in range(n - 1, -1, -1): luxury.append(max(maxH + 1 - array[i], 0)) maxH = max(maxH, array[i]) print(*luxury[::-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
n = int(input()) a = list(map(int, input().split())) b = [0] * n ma = a[-1] for i in range(n - 2, -1, -1): if a[i] <= ma: b[i] = ma - a[i] + 1 else: ma = a[i] print(*b)
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 n, i, a[100001], b[100001], k; int main() { cin >> n; for (; i < n; i++) cin >> a[i]; while (i--) { k = max(k, a[i]); b[i] = k; } for (i = 0; i < n; i++) cout << (b[i] == b[i + 1] ? b[i] - a[i] + 1 : 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
def main(): input() hh = list(map(int, input().split()))[::-1] h0 = 0 for i, h in enumerate(hh): if h0 < h: h0 = h hh[i] = 0 else: hh[i] = h0 + 1 - h print(*hh[::-1]) if __name__ == '__main__': main()
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 MAXN = 1e5 + 10; int n, h[MAXN], mx[MAXN]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> h[i]; for (int i = n; i >= 0; i--) mx[i] = max(h[i + 1], mx[i + 1]); for (int i = 0; i < n; i++) cout << max(h[i], mx[i] + 1) - h[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; cin >> n; vector<long long> a(n), res(n); for (int i = 0; i < n; i++) cin >> a[i]; long long mx = INT_MIN; for (int i = n - 1; i >= 0; i--) { res[i] = (mx >= a[i] ? mx - a[i] + 1 : 0); mx = max(mx, a[i]); } for (int i = 0; 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
import java.io.*; import java.util.*; public class Main { public static void main(String[] args)throws IOException{ PrintWriter pw = new PrintWriter(System.out); InputReader in = new InputReader(System.in); int n = in.nextInt(); int[] a = 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; int main() { int n; scanf("%d", &n); int h[n], freq[n], mflr = 0; for (int i = 0; i < n; i++) scanf("%d", &h[i]); for (int i = n - 1; i >= 0; i--) { if (h[i] > mflr) { freq[i] = 0; mflr = h[i]; } else freq[i] = mflr + 1 - h[i]; } for ...
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 N = 1007, K = 1007, INF = LONG_MAX; int n, a[150000], i, j, m[150000]; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } int mx = 0; for (i = n - 1; i >= 0; i--) { mx = max(mx, a[i]); m[i] = mx; } for (i = 0; i < n; 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> int a[1000005]; int b[100005]; int main() { int n; scanf("%d", &n); int i; for (i = 1; i <= n; i++) scanf("%d", &a[i]); int ma = 0; for (i = n; i >= 1; i--) { if (a[i] > ma) { ma = a[i]; b[i] = 0; } else { b[i] = ma + 1 - a[i]; } } for (i = 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 java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math...
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
/* * Author- Kishan_25 * BTech 2nd Year DAIICT */ import java.io.*; import java.math.*; import java.util.*; import javax.print.attribute.SetOfIntegerSyntax; public class code { private static InputStream stream; private static b...
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()) h = list(map(int, input().split())) + [0] h_max = [0] * n res = [0] * n for i in range(n - 1, 0, -1): h_max[i - 1] = max(h_max[i], h[i] + 1) res[i] = max(h_max[i] - h[i], 0) res[0] = max(h_max[0] - h[0], 0) print(" ".join(map(str, res)))
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 a[100008], a2[100008], n; int main() { cin >> n; for (long int i = 1; i <= n; i++) cin >> a[i]; long long maxi = a[n]; for (long i = n - 1; i >= 1; i--) { if (a[i] > maxi) { a2[i] = a[i] - 1; maxi = a[i]; } else if (a[i] == 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.Stack; import java.util.StringTokenizer; public class B581Alt { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader(){ br = new BufferedR...
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()) lst = list(map(int, input().split())) res = [0] k = 0 for i in range(-2, -len(lst)-1, -1): if k < lst[i+1]: k = lst[i+1] if k >= lst[i]: res.append(k-lst[i]+1) else: res.append(0) print(*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
N = int(input()) H = [int(_) for _ in input().split()] suffix_max = [0] * (N + 1) for i in range(N - 1, -1, -1): suffix_max[i] = max(H[i], suffix_max[i + 1]) ans = [0] * N for i in range(N): ans[i] = max(suffix_max[i + 1] - H[i] + 1, 0) print(' '.join(str(_) for _ 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
n=int(input()) l=list(map(int,input().split())) m=l[-1] z=[0]*n for i in range(n-2,-1,-1): if l[i]>m: m=l[i] else: z[i]=m-l[i]+1 print(*z)
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()) lst = list(map(int, input().strip().split(' '))) #n,m = map(int, input().strip().split(' ')) i=n-1 l2=[] m=0 while(i>=0): if lst[i]>m: l2.append(0) m=lst[i] elif m==lst[i]: l2.append(1) else: l2.append(m+1-lst[i]) i-=1 for j in range(n): print(l2[n-j-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.io.*; import java.util.*; import java.util.stream.Collectors; public class Solution { public static void main(String[] args) throws IOException { IO io = new IO(); int n = io.getInt() ; List<Integer> ls = io.getIntegerArray(n) ; List<Integer> res = new ArrayList<>() ; ...
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 try: while True: n = int(input()) val = list(map(int, input().split())) maxval = 0 for i in range(n-1, -1, -1): if maxval >= val[i]: val[i] = maxval - val[i] + 1 else: maxval = val[i] val[i] = 0 ...
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 flag, cnt, j, i, k, ans, maxy; long long n; int main() { cin >> n; vector<long long> v(n), temp(n), ans(n); ans[n - 1] = 0; maxy = v[n - 1]; for (i = 0; i < n; i++) { cin >> v[i]; temp[i] = v[i]; } for (i = n - 2; i >= 0; i--) { if (maxy ...
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 a[100010]; int m[100010]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { long long k; scanf("%lld", &k); a[i] = k; } m[n - 1] = a[n - 1]; for (int i = n - 2; i >= 0; i--) { m[i] = max(m[i + 1], a[i]); } for (int 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() { int n, i, k = 0; cin >> n; int h[n], a[n]; for (i = 0; i < n; i++) { cin >> h[i]; } h[n] = 0; for (i = n - 1; i >= 0; i--) { k = max(k, h[i + 1]); a[i] = k; } for (i = 0; i < n; i++) { cout << max(a[i] - h[i] + 1, 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() { long int n; cin >> n; long int large = 0; vector<int> v(n); vector<int> answer(n); for (int i = 0; i < n; i++) { cin >> v[i]; } for (int i = n - 1; i >= 0; i--) { if (v[i] > large) { answer[i] = 0; large = v[i]; } 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
import java.util.*; public class Main{ public static void main(String [] args) { Scanner scan=new Scanner(System.in); int n=scan.nextInt(); int a[]=new int[n]; int i; for(i=0;i<n;i++) { a[i]=scan.nextInt(); } int b[]=new 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 n, i, a[100001], max[100001], maxx = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; max[i] = 0; } for (i = n - 1; i >= 0; i--) { if (a[i] > maxx) { maxx = a[i]; max[i] = maxx - 1; continue; } max[i] = max...
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 conversion(string p) { int o; o = atoi(p.c_str()); return o; } string toString(int h) { stringstream ss; ss << h; return ss.str(); } long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); } long long lcm(long long a, long long b) { re...
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 maxn = 1e5 + 10; int a[maxn], maxx[maxn]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } maxx[n - 1] = a[n - 1]; for (int i = n - 2; i >= 0; i--) { maxx[i] = max(maxx[i + 1], a[i]); } for (int 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
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class LuxuriousHouses implements Closeable { private InputRead...
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
#!/usr/bin/env python from sys import stdin as cin def main(): n = int(next(cin)) a = map(int, next(cin).split()) b = [0] * len(a) for i in range(len(a)-1, 0, -1): b[i-1] = max(a[i], b[i]) return [max(b[i]-a[i]+1, 0) for i in range(len(a))] print ' '.join(map(str, 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
#BeEf_Killer_______ # / _ _ \ # / (.) (.) \ # ( _________ ) # \`-V-|-V-'/ # \ | / # \ ^ / # \ \ # \ `-_ # `-_ -_ # -_ -_ # _- _- # _- _- # _- _- #...
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
a = int(input()) b = list(map(int, input().split())) mark = 0 answer = list() for x in range(a): if b[a - x - 1] > mark: answer.append(0) mark = b[a - x - 1] else: answer.append(mark - b[a - x - 1] + 1) for x in range(a): print(answer[a - x - 1], "", end="", flush=True)
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[100001] = {0}, b[100001] = {0}; int i, k, l, m, n, o, p; int main() { scanf("%d\n", &n); for (int i = 0; i < n; i++) { scanf("%d ", &a[i]); } b[n] = a[n - 1] - 1; for (int i = n - 1; i > -1; i--) { b[i] = max(b[i + 1], a[i + 1]); } for (int 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
import java.io.*; import java.util.*; public class P581B{ static int[] run(int[] ar){ int[] max_ar = new int[ar.length]; for (int i=ar.length-1; i>-1; i--) { if(i==ar.length-1) max_ar[i] = 0; else{ if(max_ar[i+1]>ar[i+1]) max_ar[i] = max_ar[i+1]; else max_ar[i] = ar[i+1]; } } 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
n = input() a = map(int, raw_input().split()) m = [] mxm = 0 for i in range(n-1, -1, -1): mxm = max(a[i], mxm) m.append(mxm) for i in range(n-1): if a[i]>m[n-2-i]: print 0, else: print m[n-2-i]-a[i]+1, print 0
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 n; cin >> n; int ar[n], br[n], cr[n]; for (int i = 0; i < n; i++) { cin >> ar[i]; br[i] = 0; cr[i] = -1; } int max = ar[n - 1]; br[n - 1] = max; cr[n - 1] = 0; for (int i = n - 1; i >= 0; i--) { if (max < ar[i]) { max...
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 main() { int s, i, y; int f = 0; scanf("%d", &s); int n[s]; int r[s]; for (i = 0; i < s; i++) { scanf("%d", &n[i]); } int g = n[s - 1]; for (i = s - 2; i >= 0; i--) { if (n[i] > g) { g = n[i]; r[i] = 0; } else { r[i] = (g - n[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.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
import java.util.*; public class Main { public static void main(String[] args) { Scanner s=new Scanner (System.in); int n=s.nextInt(); int arr[] = new int[n]; int ans[] =new int[n]; for (int i=0;i<n;i++) { arr[i]=s.nextInt(); } int mx = arr[n-1]; ans[n-1]=0; for (int i=n-2;i>=0;i--) { if...
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; import java.util.Stack; public class q2 { public static void main(String aegs[]) { Scanner s=new Scanner(System.in); int n=s.nextInt(); int a[]=new int[n]; int ng[]=new int[n]; Stack<Integer> st=new Stack<Integer>(); 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
import java.util.*; import java.io.*; public class B { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] height = new int[n]; int[] max = new int[n]; for (int i = 0; i < n; i++) { height[i] = in.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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
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; #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") bool isPrime(long long int n) { for (long long int i = 2; i * i <= n; i++) { if (n % i == 0) { return false; } } return true; } bool isPowerOfTwo(long long...
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.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
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class CF581B { public static void main(String[] args)throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); for(String ln;(ln=in.readLine())!=n...
JAVA