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
#include <bits/stdc++.h> using namespace std; bool isPrime[1005]; void sieve(int N) { for (int i = 0; i <= N; ++i) { isPrime[i] = true; } isPrime[0] = false; isPrime[1] = false; for (int i = 2; i * i <= N; ++i) { if (isPrime[i] == true) { for (int j = i * i; j <= N; j += i) isPrime[j] = false; ...
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.PrintStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Iterator; public class Main_Round322Div2_B { public static void main(String[] args) { Scanner s...
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(raw_input()) i = [int(x) for x in raw_input().split()] out = [] m = 0 for x in range(len(i), 0, -1): if i[x-1] > m: m = i[x-1] out.append(0) else: out.append(m - i[x-1] + 1) for i in range(len(out), 0, -1): print out[i-1],
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 arr[100005], ans[100005]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) scanf("%d", &arr[i]); int maxx = arr[n - 1]; ans[n - 1] = 0; for (int i = n - 2; i >= 0; i--) { if (arr[i] > maxx) { maxx = arr[i]; ans[i] = 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
//package com.competitions.year2015.julytoseptember.round322div2; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.InputMismatchException; public fi...
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 final class Solution { public static void main(String[] args) { Reader input = new Reader(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int n = input.nextInt(); int[] arr = new int[n]; int[] res...
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(raw_input()) l = map(int, raw_input().split()) M = 0 ans = [0]*n for i in xrange(n-1, -1, -1): ans[i] = max(0, M - l[i] + 1) M = max(M, l[i]) print ' '.join(map(str, ans))
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 = 100001; void process(int a[], int dp[][maxN], int N) { int i, j; for (i = 0; i < N; i++) dp[0][i] = a[i]; for (i = 1; i <= (int)(log2(N)); i++) for (j = 0; j + (1 << (i - 1)) < N; j++) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j + (1 << (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
def solve(n, h_arr): h_arr = list(h_arr) h_increment = [0] * n largest = h_arr[n-1] for i in range(n-2, -1, -1): if h_arr[i] <= largest: h_increment[i] = largest - h_arr[i] + 1 else: largest = h_arr[i] return " ".join(str(h_inc) for h_inc in h_increment) ...
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 B { public static void main(String[] args) throws IOException { int n = nextInt(); int[] floors = new int[n + 1]; for (int i = 0; i < n; ++i) { floors[i] = nextInt(); } int[] max = new int[n + 1]; floors[n] = -1; for (int i = n - 1; i >= 0; --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 n, h[200000], a[200000]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> h[i]; for (int i = n - 1; i >= 0; i--) a[i] = max(a[i + 1], h[i + 1]); for (int i = 0; i < n; i++) cout << max(a[i] - h[i] + 1, 0) << ' '; 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
#include <bits/stdc++.h> using namespace std; const int N = 1e5; vector<int> vc; int a[N + 10]; int main() { int n, mx = 0; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = n - 1; i >= 0; i--) if (a[i] > mx) vc.push_back(0), mx = a[i]; else vc.push_back(mx - a[i] + 1); 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; int main() { int n, a[100007], b[100007]; cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; int maxi = 0; for (int i = n; i >= 1; --i) { b[i] = maxi; maxi = max(maxi, a[i]); } for (int i = 1; i <= n; ++i) if (a[i] <= b[i]) cout << abs(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
n = int(raw_input()) arrh = map(int, raw_input().split()) ans = [] ans.append(0) mx = arrh[n-1] for i in xrange(n-2, -1, -1): mx = max(arrh[i+1], mx) ans.append(max(mx-arrh[i]+1, 0)) for i in xrange(n-1, -1, -1): print ans[i], print
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() arr = map(int,raw_input().split()) new = [0] arr = arr[::-1] ma = arr[0] for i in range(1,n): if arr[i]<=ma: ans = ma-arr[i] + 1 else: ma = arr[i] ans = 0 new.append(ans) new = new[::-1] print " ".join(map(str,new))
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.lang.Math; public class C { public static void main(String args[]) { PrintWriter out = new PrintWriter(System.out); FastScanner fs = new FastScanner(); int t=1; for(int qq=1; qq <= t; qq++) { int n=fs.nextInt(); int a[] = 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
# http://codeforces.com/problemset/problem/581/B def calculate(numbers): numbers = [int(i) for i in numbers.split()] result = [] current = 0 for i in numbers[::-1]: if i <= current: result.append(current - i + 1) else: result.append(0) current = 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
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n + 1]; int ans[n + 1]; memset(ans, 0, sizeof(ans)); for (int i = 0; i < n; i++) cin >> arr[i]; int t = arr[n - 1]; for (int i = n - 2; i > -1; i--) { t >= arr[i] ? ans[i] = t - arr[i] + 1 : t = arr[i]; } for (in...
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 s(a): p=0 for i in a: p+=i[1] return p n=input() h=map(int,raw_input().split()) h.reverse() diff=[0] mh=h[0] for i in range(1,n): d=mh-h[i] if d>=0: diff.append(mh-h[i]+1) else: diff.append(0) if h[i]>mh: mh=h[i] diff.reverse() print ' '.join(ma...
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.*; public class Div2_322B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] array = new int[n]; for(int i = 0; i < n; i++) array[i] = sc.nextInt(); int[] ans = new int[n]; int max = array[n - 1]; for(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=int(raw_input()) l=map(int,raw_input().split()) ans=[0] cnt,chk=l[-1],1 for i in l[-2::-1]: if i<=cnt and chk: chk=0 ans.append(cnt-i+1) elif i<=cnt: ans.append(cnt-i+1) else: chk=1 cnt=i ans.append(0) print ' '.join(map(str,ans[::-1]))
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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.Arrays; import java.util.StringTokenizer; public class start { static int x[]; public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedRead...
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())) maxi = 0 c = [] for i in reversed(h): if i > maxi: maxi = i c.append(0) else: c.append(maxi + 1 - i) for i in reversed(c): print(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
NumberOfHouses = int(input()) Floors = list(map(int, input().split())) AddMeArr = [0]*NumberOfHouses MaxNum = Floors[-1] for i in range(NumberOfHouses-2, -1, -1): if Floors[i] > MaxNum: MaxNum = Floors[i] else: AddMeArr[i] = MaxNum - Floors[i] + 1 print(*AddMeArr, 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
#include <bits/stdc++.h> using namespace std; long long root(long long n) { long long ans = 1; while (1) { if (ans * ans > n) { return ans - 1; break; } else if (ans * ans == n) { return ans; break; } else { ans += 1; } } } int main() { long long n, i, max; cin >>...
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; long long hi[n]; long long dp[n]; for (int i = 0; i < n; i++) { cin >> hi[i]; } dp[n - 1] = 0; for (int i = n - 2; i >= 0; i--) { dp[i] = max(dp[i + 1], hi[i + 1]); } if (hi[0] > dp[0]) { cout << "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.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class B { static StringTokenizer...
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.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.util.Random; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; im...
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())) m = -1 ans = [] for i in range(n): if a[n-i-1] > m: ans.append("0") else: ans.append(str(m+1-a[n-i-1])) m = max(a[n-i-1], m) print(" ".join(ans[::-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
/** * Created by heat_wave on 12.01.15. */ import java.io.*; import java.util.Scanner; import java.util.StringTokenizer; public class A { Scanner in = new Scanner(System.in); public void solve() { int n = in.nextInt(); long [] h = new long[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
n=int(input()) h=[int(i) for i in input().split()] p=n*[0] p[-1]=0 gg=n*[0] gg[-1]=0 for i in range(n-2,-1,-1): gg[i]=max(gg[i+1],h[i+1]) for i in range(n): d=gg[i]-h[i] if d<0: d=0 p[i]=d else: p[i]=d+1 for i in range(n): print(p[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()) ans = [] ma = 0 for h in list(reversed(list(map(int, input().split())))): ans += [max(0, ma - h + 1)] ma = max(ma, h) print(' '.join(map(str, reversed(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; vector<pair<long long int, long long int> > v; pair<long long int, long long int> p; int main() { long long int x, y, z, n, a[100002], b[100002], c, i, j, need; while (cin >> n) { v.clear(); for (i = 0; i < n; i++) { cin >> x; b[i] = x; } 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
n = input() a = map(int, raw_input().split()) b = [0]*n b[0] = 0 a.reverse() max = a[0] for i in range(1, n): if a[i] > max: b[i] = 0 max = a[i] else: b[i] = max + 1 - a[i] b.reverse() for i in range(n): print b[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()) houses = [int(c) for c in input().split()] ans = [0] * n max_ = -1 for i in range(n - 1, -1, -1): ans[i] = max_ - houses[i] + 1 if houses[i] <= max_ else 0 max_ = max(max_, houses[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; long long int n, height[100005], maxR[100005]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> height[i]; maxR[n] = height[n - 1] - 1; maxR[n - 1] = height[n - 1]; for (int i = n - 2; i >= 0; i--) maxR[i] = max(maxR[i + 1], height[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.*; import java.util.*; public class LuxuriousHouses { public static void main(String args[]){ FScanner in = new FScanner(); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int arr[]=in.readArray(n); int copy[]=new int[n+1]; int max=arr[n-1],a=0;long sum=0; for(int 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
__author__ = 'Admin' n = int(input()) mas1 = list(map(int, input().split())) masans = [0] max = mas1[n - 1] for i in range(n - 2, -1, -1): if mas1[i] > max: max = mas1[i] masans.append(0) else: masans.append(max - mas1[i] + 1) masans.reverse() print(*masans)
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()) seq = [int(x) for x in raw_input().split()] seq.reverse() cur_max = seq[0] result = [0] for elem in seq[1:]: if elem > cur_max: result.append(0) cur_max = elem else: result.append(cur_max - elem + 1) for elem in result[::-1]: print elem,
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; void solve() { long long n; cin >> n; ; long long a[n]; for (long long i = 0; i < n; i++) cin >> a[i]; long long mx[n]; mx[n - 1] = 0; for (long long i = n - 2; i >= 0; i--) { mx[i] = max(a[i + 1], mx[i + 1]); } for (long long 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> using namespace std; int main() { int n; cin >> n; int data[n]; map<int, int> cnt; for (int i = 0; i < n; ++i) { cin >> data[i]; ++cnt[data[i]]; } for (int i = 0; i < n; ++i) { if (cnt.crbegin()->first == data[i]) cout << (cnt.crbegin()->second == 1 ? 0 : 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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.PrintStream; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Mehul Sharma */ public class Main { public static void main(Strin...
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()) string = input() numbers = string.split(" ") for x in range(n): numbers[x] = int(numbers[x]) floors = [] maximum = numbers[n - 1] for x in range(n - 2, -1, -1): a = numbers[x] if a > maximum: maximum = a floors.append("0") else: floors.append(str(maximum - a + 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.IOException; import java.io.PrintWriter; import java.util.Scanner; public class luxuriousHouses { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub // BufferedReader b=new BufferedReader(new InputStreamReader(System.in)); Scanner scan=new Scanner(Syste...
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()) houses = list(map(int, input().split(' '))) answers = [] mh = 0 for h in houses[::-1]: if mh >= h: answers.append(mh - h + 1) else: answers.append(0) mh = max(mh, h) print(' '.join(map(str, answers[::-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; int main() { int n, x; ios_base::sync_with_stdio(0); cin >> n; vector<int> v(n); for (int i = 0; i < n; ++i) { cin >> x; v[i] = x; } int max = -1, tmp; vector<int> m(n); for (int i = v.size() - 1; i >= 0; --i) { tmp = max; if (v[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
n = int(input()) lst = list(map(int, input().split())) dp = [-1000] * n dp[n - 1] = 0 for i in range(len(lst) - 2, -1, -1): dp[i] = max(dp[i + 1], lst[i + 1]) for i in range(n): if dp[i] >= lst[i]: print(dp[i] - lst[i] + 1, 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
n=int(input()) a=list(map(int,input().split())) x=1 r=[] for i in range(n-1,-1,-1):r+=[max(x-a[i],0)];x=max(x,a[i]+1) print(' '.join(map(str,r[::-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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution ...
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, arr[100005], arrAns[100005]; cin >> n; for (int i = 0; i < n; i++) cin >> arr[i]; int max = arr[n - 1]; for (int i = n - 2; i >= 0; i--) { if (arr[i] <= max) arrAns[i] = (max - arr[i]) + 1; else { arrAns[i] = 0; 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 N = (int)1e5 + 1; int main() { std::ios::sync_with_stdio(0); long long int n; cin >> n; long long int a[n], max[n]; for (int i = 0; i < n; i++) cin >> a[i]; long long int ma = a[n - 1]; max[n - 1] = a[n - 1]; for (int i = n - 2; i >= 0; 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; vector<int> v; int main() { int n, i, val, sub = 0; cin >> n; int arr[n + 5]; for (i = 0; i < n; i++) { cin >> arr[i]; } val = arr[n - 1]; v.push_back(0); for (i = n - 2; i >= 0; i--) { if (arr[i] <= val) { sub = (val - arr[i]) + 1; v.pus...
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 if __name__=="__main__": n=int(input()) a=list(map(int,input().split())) ma=a[n-1] ans=[0] i=n-2 while i>=0: if a[i]>ma: ans.append(0) ma=a[i] else: d=(ma-a[i])+1 ans.append(d) i=i-1 ans.reverse() 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
__author__ = 'hariprahal' def main(): n = int(raw_input()) array = raw_input().split() array = [int(i) for i in array] max1 = array[n - 1] array[n - 1] = 0 str1 = '' for i in range(n - 2, -1, -1): if array[i] > max1: max1 = array[i] array[i] = 0 el...
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().strip()) arr = list(map(int, input().strip().split())) currMax = 0 ans = [0]*n for i in range(n-1, -1, -1): ans[i] = max(0, currMax-arr[i]+1) currMax = max(currMax, arr[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
x = int(input()) inp = input().split() out = [] maxh = 0 for i in reversed(range(0,x)): j = int(inp[i]) if j <= maxh: out.append(maxh - j + 1) else: out.append(0) maxh = j s = "" for i in reversed(out): s += str(i) + " " print(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
#include <bits/stdc++.h> using namespace std; long long h[100000]; int main() { int n; cin >> n; for (int j = 0; j < n; ++j) { cin >> h[j]; } long long max = h[n - 1]; long long answer[100000]; answer[n - 1] = 0; for (int i = n - 2; i >= 0; --i) { if (h[i] > max) { max = h[i]; answer...
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())) out = [0] best = h[-1] for i in range(n-2, -1, -1): if h[i] < best: out.append(best - h[i] + 1) elif h[i] > best: best = h[i] out.append(0) else: out.append(1) print(" ".join(map(str, reversed(out))))
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(x) for x in input().split()] assert len(l) == n l.reverse() pre = [0] for i in range(1, n): pre.append(max(pre[-1], l[i-1])) out = [max(0, 1+pre[i]-l[i]) for i in range(n)] out.reverse() print(' '.join(str(x) for x in out))
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()) b=[] mx=0 for i in xrange(n-1,-1,-1): if mx>=a[i]: b.append(mx-a[i]+1) else : b.append(0) mx=max(mx,a[i]) #print a[i] for i in xrange(len(b)-1,-1,-1): print b[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
import java.util.Scanner; /** * Created on 28/09/2015. */ public class B { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] houses = new int[n]; for (int i = 0; i < n; i++) { houses[i] = s.nextInt(); } int[] maxHeights = new int[n]; 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; int main() { long long i, maxi, n; cin >> n; long long A[n]; for (i = 0; i < n; i++) cin >> A[i]; maxi = A[n - 1]; long long maxii[n]; maxii[n - 1] = 0; for (i = n - 2; i >= 0; i--) { if (A[i] <= maxi) maxii[i] = maxi + 1 - A[i]; else { 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.io.InputStream; import java.util.Arrays; import java.util.InputMismatchException; public class B581 { static InputStream is; public static void main(String[] args) { is = System.in; solve(); } static void solve() { int n = ni(); int[] h = new int[n]; 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()) ai = list(map(int,input().split())) maxm = ai[n-1] bi = [0]*n for i in range(len(ai)-2,-1,-1): bi[i] = max(0,maxm+1-ai[i]) if ai[i] > maxm: maxm = ai[i] print(*bi)
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(): input() hh = list(map(int, input().split()))[::-1] h0 = 0 for i, h in enumerate(hh): if h0 < h: h0 = h hh[i] = 0 elif h0 > h: hh[i] = h0 + 1 - h else: hh[i] = 1 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; int main() { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v.at(i); vector<int> w(n); w.at(n - 1) = 0; int k = v.at(n - 1); for (int i = n - 2; i >= 0; i--) { if (v.at(i) > k) { w.at(i) = 0; k = v.at(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
//package codeForces; import java.util.Scanner; public class LuxuriousHouse { static int findMax(int r,int l,int[]arr){ int max=arr[r]; for(int i=r;i<l;i++){ if(arr[i]>max)max=arr[i]; } return max; } public static void main(String[]args){ Scanner scanner...
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 Codeforces581BLuxeryHouse { public static void main(String[] args) { int a, b, sum = 0; Scanner scanner = new Scanner(System.in); a = scanner.nextInt(); int[] arr = new int[a]; for (int i = 0; i < a; i++) { arr[i] = scanner.nextInt(); } int[] answer = new int[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
#include <bits/stdc++.h> using namespace std; int main() { long long n, i, j, arr[100001], b[100001] = {0}, temp, ans, maxright = 0; cin >> n; for (i = 0; i < n; i++) { cin >> arr[i]; } b[n - 1] = arr[n - 1]; maxright = arr[n - 1]; for (i = n - 2; i >= 0; i--) { temp = arr[i]; b[i] = maxright;...
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() house = map(int,raw_input().split()) ans = [0] * n maxi = house[-1] for i in range(n-2,-1,-1): ans[i] = max(maxi+1-house[i],0) maxi = max(maxi,house[i]) print ' '.join(str(i) for i in ans)
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; void next(long long int a[], long long int n) { long long int i; long long int max = a[n - 1]; a[n - 1] = -1; for (i = n - 2; i >= 0; i--) { long long int temp = a[i]; a[i] = max + 1; if (max < temp) max = temp; } } int main() { long long int n, a[10...
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() l = map(int, raw_input().split()) ma = 0 a = [0]*n for i in range(n - 1, -1, -1): a[i] = max(0, ma + 1 - l[i]) ma = max(ma, l[i]) for i in range(n): print a[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
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100; long long int a[maxn], dp[maxn]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = n; i >= 1; i--) { dp[i] = max(a[i], dp[i + 1]); if (a[i] > dp[i + 1]) { a[i] = 0; } else { 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
a = input() b = map(int, raw_input().split()) def luxhouse(a, b): c = [] lux = 0 for x in reversed(xrange(a)): if b[x] > lux: lux = b[x] c.append(0) else: c.append(lux+1-b[x]) print " ".join(str(x) for x in reversed(c)) luxhouse(a, 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
#include <bits/stdc++.h> const double EPS = 1e-24; const long long int MOD = 1000000007ll; const long long int MOD1 = 1000000009ll; const long long int MOD2 = 1100000009ll; const double PI = 3.14159265359; int INF = 2147483645; long long int INFINF = 9223372036854775807; template <class T> T Max2(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
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Ideone { public static void main (String[] args) throws java.lang.Exception { // your code goes here int n,b; Scanne...
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 = [int(s) for s in input().split()] # list of maxima: element i is max(h[i:]) m = [0] * n m[n-1] = h[n-1] for i in reversed(range(n-1)): m[i] = max(h[i], m[i+1]) a = [max(0, m[i+1]+1 - h) for i, h in enumerate(h[:-1])] + [0] print(" ".join(str(x) for x in 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; const int maxn = 1e5 + 500; int n, p[maxn], maxv[maxn]; int main(int argc, char *argv[]) { std::ios::sync_with_stdio(false); std::cin.tie(0); cin >> n; for (int i = 0; i < n; ++i) cin >> p[i]; int ptr = 0; for (int i = n - 1; i >= 0; --i) { maxv[i] = ptr; ...
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.Arrays; import java.util.Scanner; public class Luxurioushouse { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int n = input.nextInt(); int[] arr = new int[n]; int[] brr = new int[n]; 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 n, i, a[100005], r[100005], m; int main() { cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; } r[n] = 0; for (i = n - 1; i >= 1; i--) { m = max(m, a[i + 1]); r[i] = m; } for (i = 1; i <= n; i++) { if (r[i] >= a[i]) { cout << r[...
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 INF = (int)1e9; const int SIZE = 100005; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; vector<int> v(n), res(n); vector<pair<int, int> > vp; for (int i = 0; i < n; i++) cin >> v[i]; int mx = 0; vp.push_back(make_pair(n - 1, v[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
__author__ = 'aste' def main(): n = int(raw_input()) h = [int(x) for x in raw_input().split()] m = 0 i = n - 1 a = [] while i >= 0: a.append(max(0, m + 1 - h[i])) m = max(m, h[i]) i -= 1 i = n - 1 while i >= 0: print a[i], i -= 1 if __name__ == "...
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, m = 0; cin >> n; int a[100005], b[100005]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = n - 1; i >= 0; i--) { if (a[i] > m) { m = a[i]; b[i] = 0; } else { b[i] = m - a[i] + 1; } } for (int 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> #pragma optimize("O3") using namespace std; const long long MOD = 1e9 + 7; const long long INF = 1e18 + 7; const int base = 2e5 + 1; const long long MAX = 1e6; const double EPS = 1e-9; const double PI = acos(-1.); const int MAXN = 2 * 1e5 + 147; mt19937 rng(chrono::steady_clock::now().time_sinc...
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())) a = [0] max1 = l[-1] for i in range(n - 2, -1, -1): if l[i] > max1: max1 = l[i] a.append(0) else: a.append(max1 - l[i] + 1) print(*a[::-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 Driver { public static Scanner scanner; public static void main(String[] args) { scanner = new Scanner(System.in); int n = scanner.nextInt(); int a[] = new int[n]; for(int i=0; i<n; i++) a[i] = scanner.nextInt(); int b[] = new int[n]; b[n-1]=0; for(int 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; cin >> n; vector<int> A(n), M(n); for (int i = 0; i < n; i++) { cin >> A[i]; } int maxi = -1; for (int i = n - 1; i >= 1; i--) { maxi = max(maxi, A[i]); M[i] = maxi; } vector<int> res; for (int i = 0; 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
n=int(input()) a=list(map(int,input().split())) b=[0]*n mx=a[n-1] for i in range(n-2,-1,-1): b[i]=max(0,mx-a[i]+1) if a[i]>mx:mx=a[i] print(*b) # Made By Mostafa_Khaled
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 { static BufferedReader in; static PrintWriter out; static StringTokenizer tok; static String next() throws IOException{ while ( tok == null || !tok.hasMoreTokens()){ tok = new StringTokenizer(in.readLine()); } return tok.nextT...
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(0); cin.tie(NULL); int n, mx; cin >> n; int a[n], b[n]; for (int i = 0; i < n; ++i) cin >> a[i]; b[n - 1] = 0; mx = a[n - 1]; for (int i = n - 2; i >= 0; --i) { mx = max(mx, a[i + 1]); if (mx >= a[i]) 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 A[100002]; int Max[100002]; int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; for (int i = 1; i <= N; i++) { cin >> A[i]; } Max[N] = 0; for (int i = N - 1; i > 0; i--) { Max[i] = max(A[i + 1], Max[i + 1]); } for (int 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; long long n, a[500005], cmax, d[500005], ans; int main() { ios::sync_with_stdio(0); ; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = n - 1; i >= 0; i--) { d[i] = cmax; cmax = max(cmax, a[i]); } for (int i = 0; i < n; i++) { if (d[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
from sys import * input = lambda:stdin.readline() int_arr = lambda : list(map(int,stdin.readline().strip().split())) str_arr = lambda :list(map(str,stdin.readline().split())) get_str = lambda : map(str,stdin.readline().strip().split()) get_int = lambda: map(int,stdin.readline().strip().split()) get_float = lambda : m...
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.BufferedInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.InputMismatchException; public class Main { class MyScanner { private byte[] buf = new byte[1024]; private int curChar; private int numChars; BufferedInputS...
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() { long long int n; cin >> n; long long int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; vector<long long int> b(n, 0); for (int i = n - 2; i >= 0; i--) { b[i] = a[i + 1] - a[i]; } long long int s = 0; for (int 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
#include <bits/stdc++.h> using namespace std; int main() { int x; scanf("%d", &x); int arr[x]; for (int i = 0; i < x; i++) { scanf("%d", &arr[i]); } int maxi = arr[x - 1]; vector<int> v; v.push_back(0); for (int i = x - 2; i >= 0; i--) { if (arr[i] <= maxi) { v.push_back(maxi - arr[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
from sys import stdin n = int(stdin.readline()) hi = list(map(int, stdin.readline().split())) res = [''] * n vmax = 0 for i in range(n - 1, -1, -1): if vmax < hi[i]: vmax = hi[i] res[i] = '0' else: res[i] = str(vmax - hi[i] + 1) print(" ".join(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
import java.util.Scanner; import java.util.Vector; public final class e{ final int N=205123; public void solve(){ Scanner in = new Scanner(System.in); int a[]=new int[N]; int b[]=new int[N]; int n,mx; n=in.nextInt(); for(int i=0;i<n;++i) a[i]=in.nextI...
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
#------------------------------what is this I don't know....just makes my mess faster-------------------------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer =...
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() t=map(int,raw_input().split()) t.reverse() m=t[0] li=[0] for i in xrange(1,n): if t[i]>m: m=t[i] li+=[0] else: li+=[m+1-t[i]] li.reverse() for i in li: print i,
PYTHON