prompt
string
response
string
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i = 0, l = -2, k = INT_MAX, j, a = 0, f = 0, c = 0, b = 0, x = 100000000007, d, y, m, zero = 0, one = 0, z; string s = "qwertyuiopasdfghjkl;zxcvbnm,./", mar, maria; char cha; vector<long long int> vc, vct, vctt; vec...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(input()) arr = list(map(int, input().split())) maxarr = [0]*n maxarr[n-1] = arr[-1] curmax = maxarr[-1] index = n-1 for val in arr[::-1]: maxarr[index] = max(val, curmax) curmax = maxarr[index] index -= 1 for index, val in enumerate(arr): out = 0 if maxarr[index] == val: if index + 1...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int main() { int n; long long h[100000], ans[100000]; cin >> n; for (int i = 0; i < n; i++) cin >> h[i]; ans[n - 1] = 0; for (int i = n - 2; i >= 0; i--) { if (h[i] <= h[i + 1]) ans[i] = h[i + 1] - h[i] + 1; else ans[i] = 0; h[i] = max(h[...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n=int(input()) h=list(map(int,input().split())) l=[] m=h.pop() l.append(0) while h: if h[-1]<=m: l.append(m-h[-1]+1) m=max(m,h.pop()) else: l.append(0) m=max(m,h.pop()) for i in range(len(l)-1,-1,-1): print(l[i],end=' ')
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class B { public B() { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); List<Integer> list = new ArrayList<Integer>(); for(int i=0; i<n; i++) { list.add(scanner....
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int arr[n]; for (int(i) = 0; (i) < (n); ++(i)) { cin >> arr[i]; } long long int m = arr[n - 1]; long long int out[n]; out[n - 1] = 0; for (int(i) = (n - 2); (i) >= (0); --(i)) { if (arr[i] > m) { out[i]...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
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(...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(raw_input()); inp = raw_input().split(); inp.reverse(); mx = -1; ans=[]; for el in inp: x = int(el); if mx == -1 or x > mx: ans.append('0') else: ans.append(str(mx - x + 1)) mx = max(mx, x); ans.reverse(); print " ".join(ans);
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.util.Arrays; import java.util.Scanner; import java.util.Vector; public class Luxurious_Houses { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); Vector<Object> v = new Vector<>(); long[] arr = new long[n]; // ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int ar[100001]; int maxi[100001]; int main() { int n, i; scanf("%d", &n); maxi[n] = 0; for (int(i) = (0); (i) < (n); ++(i)) { scanf("%d", &ar[i]); } for (int(i) = (n - 1); (i) >= (0); --(i)) { maxi[i] = max(maxi[i + 1], ar[i]); } for (int(i) = (0); (...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.io.PrintWriter; import java.util.Scanner; public class luxuryhooses { public static void main(String[] args) { Scanner scan = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = scan.nextInt(); int[] houses = new int[n]; for(int i = 0; i < n; i++) houses[i] = scan.nex...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; multiset<int> ss; int a[100007]; int main() { int n; while (cin >> n) { ss.clear(); for (int i = 1; i <= n; i++) { cin >> a[i]; ss.insert(a[i]); } int t, v; for (int i = 1; i <= n; i++) { if (i == n) { if (i == 1) ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(input()) h = [int(i) for i in input().split()] l = [] l_2 = [0] * n l_2[n-1] = h[n-1] for i in range (n-2, 0, -1): l_2[i] = max( l_2[i+1], h[i]) l_2 = l_2 + [0] l = [0] * n for i in range (n): m = l_2[i+1] g = max ( m - h[i] +1, 0) l[i] = g for i in l: print(i, end=' ')
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
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.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; const int MAX = 100005; int main() { int n, A[MAX], M[MAX]; while (scanf("%d", &n) == 1) { for (int i = 0; i < n; i++) scanf("%d", &A[i]); M[n - 1] = -1; for (int i = n - 2; i > -1; i--) M[i] = max(M[i + 1], A[i + 1]); for (int i = 0; i < n; i++) i...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; using namespace std; template <class T1, class T2> using p = pair<T1, T2>; template <class T1, class T2> using m = vector<pair<T1, T2>>; template <class T> using vv = vector<vector<T>>; template <class T> ostream &operator<<(ostream &os, const vector<T> &t) { os << "{"; ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(input()) arr = list(map(int,input().split())) cur = arr[n - 1] dp= [0] * (n) for i in range(n - 2 , -1 , - 1): if arr[i] > cur : dp[i] = 0 cur = arr[i] else: dp[i] = cur - arr[i] + 1 print(*dp)
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.io.*; import java.math.*; import java.util.*; public class LuxioriousHouses { public static void main(String[] args) { Scanner sc = new Scanner(); int n=sc.nextInt(); int[] arr=new int[n]; long[] b=new long[n]; arr=sc.nextIntArray(n); long max=arr[n-1]; b[n-1]=0; for(int i=n-2;i>=0;i--) ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int main() { int n, a[200000], maxs[200000]; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } maxs[n - 1] = a[n - 1]; for (int i = n - 2; i >= 0; i--) { maxs[i] = max(maxs[i + 1], a[i]); } for (int i = 0; i < n - 1; i++) { cout << max(maxs[...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.util.*; import java.io.*; public class Main { public static void main(String [] args)throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int array[] = new int[n]; StringTokenizer st = new StringTokenizer(br.readLine()); fo...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int main() { int n, max = 0; cin >> n; vector<long long> v(n), out(n); for (int i = 0; i < n; i++) { cin >> v[i]; } max = v[n - 1]; out[n - 1] = 0; for (int i = n - 2; i >= 0; i--) { if (v[i] <= max) { out[i] = (max - v[i] + 1); } else { ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(input()) arr = [int(x) for x in input().split()] m = [0] * (n+1) ans = [0] * (n+1) for i in range(n-2,-1,-1): m[i] = max(m[i+1], arr[i+1]) ans[i] = max(m[i] - arr[i] + 1, 0) print(*ans[:-1])
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(input()) input = list(map(int, input().split())) output = [0 for x in range(len(input))] m = 0 for i in range(n - 1, -1, -1): output[i] = max(0, m - input[i] + 1) m = max(m, input[i]) print(' '.join(str(output[i]) for i in range(len(output))))
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int A[100005]; int Tree[400005]; void build(int node, int left, int right) { if (right < left) return; if (left == right) { Tree[node] = A[left]; return; } build(2 * node, left, (left + right) / 2); build(2 * node + 1, (left + right) / 2 + 1, right); Tre...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> const int mod = 1E9 + 7; const int intmax = 1E9 + 7; using namespace std; int aa[100005]; int bb[100005]; int main() { ios::sync_with_stdio(0); int test, a, b, c; int n; cin >> n; for (int i = 0; i < n; i++) cin >> aa[i]; bb[n - 1] = aa[n - 1]; for (int i = n - 2; i >= 0; i--) { ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
a = input() b = map(int,raw_input().split()) c = [] maxH = 0 for i in b[::-1]: c.append(max(0,maxH-i+1)) maxH = max(i,maxH) u = "" for i in c[::-1]: u += str(i)+" " print u
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(input()) a = list(map(int, input().split(' ')[:n])) b = [0 for i in range(n)] m = 0 for i in range(n-1, -1, -1): b[i] = max(0, m - a[i] + 1) m = max(m, a[i]) print(*b)
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n=int(input()) l=[int(x) for x in input().split()] a=[0]*n m=l[n-1] for i in range(n-2,-1,-1): if l[i]>m: a[i]=0 m=l[i] else: a[i]=m-l[i]+1 for x in a: print(x,end=" ")
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int ara[100004], ara2[100004]; int main() { int n, i, j, k, l, ans = 0; cin >> n; for (i = 0; i < n; i++) cin >> ara[i]; for (i = n - 1; i >= 0; i--) { ara2[i] = max(ara2[i + 1], ara[i + 1]); } for (i = 0; i < n; i++) { ans = max(ara2[i] - ara[i] + 1, 0)...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(),i,max = 0,z; int[] houses = new int[n]; int[] levelup = new int[n]; for(i=0;i<n;i++){ houses[i] = sc.nextInt(); ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(input()) l = list(map(int,input().split())) max1 = l[-1] stack = [0] for i in range(2,n+1): if l[-i] == max1: stack.append(1) elif l[-i] > max1: max1 = l[-i] stack.append(0) else: stack.append(abs(l[-i]-max1)+1) for i in range(len(stack)): print(stack.pop(),end=" ")
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(input()) h = tuple(map(int, str.split(input()))) hm = [0] * (n) ch = 0 for i, x in enumerate(reversed(h)): hm[i] = max(0, ch - x + 1) ch = max(ch, x) print(str.join(" ", map(str, reversed(hm))))
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(input()) hs = list(map(int, input().split())) def solve(n, hs): dp = [0] * n zeros = [0] * n maxh = 0 for i in range(n-1, -1, -1): if hs[i] > maxh: zeros[i] = 1 maxh = hs[i] dp[i] = maxh result = [] for i in range(n): if zeros[i]: ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
__author__ = 'mowayao' n = int(raw_input()) a = map(int,raw_input().split()) M = -1 ans = [] for i in xrange(n-1,-1,-1): if M < a[i]: ans.append(0) M = a[i] elif M==a[i]: ans.append(1) else: ans.append(M-a[i]+1) for i in xrange(n-1,-1,-1): print ans[i],
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int isP(long int hj) { long int op; for (op = 2; op <= sqrt(hj); op++) { if (hj % op == 0) return 0; } return 1; } void swap(long long int *p, long long int *q) { long long int tmp = *p; *p = *q; *q = tmp; } int mind(long long int p) { int mindd = 10; ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = input() h = map(int, input().split()[::-1]) m_h = 0 res = [] for h in h: if m_h < h: res.append('0') m_h = h else: res.append(str(m_h - h + 1)) print(" ".join(res[::-1]))
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
/** * Created by lq on 15/9/30. */ import java.util.*; import java.io.*; public class b_Luxurious_Houses { public static void main(String[] args){ // FileInputStream fis = null; // try { // fis = new FileInputStream("/Users/lq/leetcode/codeforces/virtual1/1.txt"); // }catch(Excep...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int n, arr[110000], b[110000]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } for (int i = n - 2; i >= 0; i--) { b[i] = arr[i + 1] - arr[i] + 1; arr[i] = max(arr[i + 1], arr[i]); if (b[i] < 0) b[i] = 0; } for (int i = 0; i ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#!/usr/bin/env python I = raw_input def ia(): return map(int, I().split()) def na(n): return [ia() for _ in range(n)] I() arr = ia() res = [0]*len(arr) most = 0 for i in range(len(arr)-1, -1, -1): if arr[i] > most: res[i] = 0 most = arr[i] else: res[i] = most-arr[i] +1 print " ".join...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> int main() { int a; scanf("%d", &a); long A[a], B[a]; for (int i = 0; i != a; ++i) { scanf("%ld", &A[i]); } B[a - 1] = 0; long mx = A[a - 1]; for (int i = a - 2; i >= 0; --i) { if (mx < A[i]) B[i] = 0; else B[i] = mx + 1 - A[i]; mx = std::max(A[i], mx...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int N, fl[111111], ans[111111], mfl; int main() { scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%d", &fl[i]); } for (int i = N - 1; i >= 0; i--) { ans[i] = max(0, mfl + 1 - fl[i]); mfl = max(mfl, fl[i]); } for (int i = 0; i < N; i++) { pr...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.util.*; public class fence { //static {System.out.println("hello"); } public static void main(String args[]) { Scanner scn=new Scanner(System.in); int n=scn.nextInt(); if (n==1 ){ System.out.println(0); System.exit(0);} int a[]=new int[n]; int max[]=new int[n]; int max2[]=new int...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.io.BufferedReader; 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.lang.reflect.Array; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arra...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; inline long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } inline long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); } const long long mod = (long long)(1e9 + 7); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); signed main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); cout.precision(3); long long n; cin >> n; vector<long long> a(n); for (long long i = 0; i < n; i++) cin >> a[...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
# =================================== # (c) MidAndFeed aka ASilentVoice # =================================== # import math # import collections # import string # =================================== n = int(input()) q = [int(x) for x in input().split()] vmax = -1 for i in range(n-1, -1, -1): t = q[i] if (q[i] > vmax...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long a[n], b[n]; for (int i = 0; i < n; i++) cin >> a[i]; long long mx = a[n - 1]; b[n - 1] = 0; for (int i = n - 2; i >= 0; i--) { if (a[i] <= mx) b[i] = mx + 1 - a[i]; else b[i] = 0; mx = max(a[i], m...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int n, h[100001]; priority_queue<pair<int, int> > pq; void input() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &h[i]); pq.push(pair<int, int>(h[i], -i)); } } void solve() { input(); for (int i = 0; i < n; i++) { while (pq.size() && -pq...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
def luxurious_houses(): houses = int(raw_input().strip()) height_of_houses = list(map(int, raw_input().strip().split())) max_height_array = [0] * houses max_height_array[houses - 1] = height_of_houses[houses - 1] for i in range(houses - 2, -1, -1): max_height_array[i] = max(max_height_array[...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
k = int(input()) houses = list((map(int, input().split()))) maxim = 0 answer = [] for i in range(len(houses)-1, -1, -1): currentVal = houses[i] if maxim < currentVal: answer.append(0) maxim = currentVal else: answer.append(maxim-currentVal+1) print(" ".join(reversed([st...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, n, t = 1; while (t--) { cin >> n; vector<long> v(n), b(n), ans(n, 0); for (i = 0; i < n; i++) { cin >> v[i]; b[i] = v[i]; } for (i = n - 2; i >= 0; i--) { if (b[i + 1] >= v[i]) ans[i] = 1 + b[i + 1] - v[i];...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#Solved by Fuad Ashraful BBabu #soled date 12 july 2019 #verdict : AC N=int(input()) tini=list(map(int,input().split())) max_height=0 diff=N*[0] for i in range(N).__reversed__(): if tini[i]>max_height: max_height=tini[i] diff[i]=0 else: diff[i]=max_height-tini[i]+1 print(*diff)
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n=int(input()) h=list(map(int,input().split())) m=max(h) l=h.index(m) i=n-2 a=[0] maxh=h[n-1] while(i>=0): if(maxh==h[i]): a.append(1) else: maxh = max(h[i], maxh) if(maxh==h[i]): a.append(0) else: a.append(maxh-h[i]+1) i-=1 a.reverse() for i in a: ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> res(n, 0); int mx = a[n - 1]; for (int i = n - 2; i >= 0; i--) { if (a[i] > mx) { mx = a[i]; res[i] = 0; } else { int diff = mx - a...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int h[n]; for (int i = 0; i < n; i++) cin >> h[i]; int max; int a[n]; a[n - 1] = 0; max = h[n - 1]; for (int i = n - 2; i >= 0; i--) { if (h[i] > max) { a[i] = 0; max = h[i]; } else { a[i] = max - h[i...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; const int E9 = 1e9; const int E8 = 1e8; const int E7 = 1e7; const int E6 = 1e6; const int E5 = 1e5; const int E4 = 1e4; const int E3 = 1e3; const int N = 5e5 + 7; const int INF = 1e9; const long long inf = 1e18; int a[N], mx[N]; bool us[N]; int main() { int n, k = 0; sc...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n; cin >> n; vector<long long> v; int num; for (int i = 0; i < n; i++) { cin >> num; v.push_back(num); } int mx = 0; vector<int> ans; for (int i = v.size() - 1; i >= 0; i--) { ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.util.*; public class L { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int n = sc.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) arr[i] = sc.nextInt(); int tallest = -1; int[] a...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = input() h= map(int,raw_input().split()) maxh=0 ans=[] for i in xrange(n-1,-1,-1): if h[i]>maxh : ans.append('0') maxh = h[i] else : ans.append(str((maxh-h[i])+1)) print " ".join(ans[-1::-1])
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> int main() { int n, i, j, k, m, l; scanf("%d", &n); int a[n], b[n]; for (i = 0; i < n; i++) { scanf("%d", &a[i]); } m = a[n - 1]; b[n - 1] = 0; for (i = n - 2; i >= 0; i--) { if (a[i] > m) { b[i] = 0; m = a[i]; } else { b[i] = m - a[i] + 1; } ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
if __name__ == '__main__': n = str(input()) line = [int(it) for it in str(input()).split()] line.reverse() res = list() mark = 0 for it in line: res.append(str(max(1 + mark - it, 0))) mark = max(mark, it) res.reverse() print(' '.join(res))
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.io.*; import java.math.*; import java.util.*; import java.util.stream.*; @SuppressWarnings("unchecked") public class P581B { public void run() throws Exception { int n = nextInt(); int [] h = readInt(n); int [] a = new int [n]; int mh = 0; for (int i = n - 1; i >= 0; i--) { a[...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; long long a[100010], b[100010]; int main() { long long n, m; cin >> n; m = -2147483647; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = n - 1; i >= 0; i--) { if (a[i] <= m) b[i] = m - a[i] + 1; else b[i] = 0; m = max(m, a[i]); } f...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.util.Scanner; /** * Created by yuu on 26/3/17. */ public class Problem581B { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] heights = new int[n]; int[] maxHeights = new int[n]; int[] results = new int[n]...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n=int(input()) l=list(map(int,input().split())) k=l[n-1] y=[0] for i in range(1,n): if k<l[n-i-1]: k=l[n-i-1] y.append(0) else: y.append(k+1-l[n-i-1]) for i in range(n): print(y[n-i-1],end=' ')
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(input()) h = [int(i) for i in input().split()] l = [] l_2 = [] for i in range(n): l_2 += [0] l_2[n-1] = h[n-1] for i in range (n-2, 0, -1): l_2[i] = max( l_2[i+1], h[i]) l_2 = l_2 + [0] for i in range (n): m = l_2[i+1] g = max ( m - h[i] +1, 0) l += [g] for i in l: print(i, en...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.util.*; import java.io.*; public class B581 { public static void main(String[] args) { Scanner in = new Scanner(System.in); long n = in.nextLong(); long[] h = new long[(int)n]; long temp=0; for(int i=0;i<n;i++) h[i]=in.nextLong(); for(int i=(int)n-1;i>=0;i--) { if(h[i]>te...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n], b[n]; for (int i = 0; i < n; i++) cin >> a[i]; int mx = a[n - 1]; for (int i = n - 2; i >= 0; i--) { if (a[i] <= mx) b[i] = mx + 1 - a[i]; else mx = a[i], b[i] = 0; } b[n - 1] = 0; for (int i = 0;...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(input()) a = [int(x) for x in input().split()][::-1] ans = [] m = 0 for i in range(len(a)): if i == 0: ans.append(0) m=a[i] else: if a[i] <= m: ans.append(m-a[i]+1) else: ans.append(0) m = a[i] ans = ans[::-1] for i in ans: print...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.util.*; public class lux{ public static void main(String[] args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++){ a[i]=s.nextInt(); } int max=0; for(int i=n-1;i>=0;i--){ if(a[i]>...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; long long int arr[100010]; long long int ans[100010]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } ans[n - 1] = 0; long long int maxi = arr[n - 1]; for (int i = n - 2; i >= 0; i--) { if (arr[i] > maxi) { ans[i] = 0...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.io.*; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.fill; public class Main { public static void main(String[] args) throws IOException { run(); end(); } static void run() throws IOException { int n = n...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(input()) l = list(map(int, input().split())) m = l[-1] l[-1] = 0 for i in range(n-2, -1, -1): if l[i] == m: l[i] = 1 elif l[i] > m: m = l[i] l[i] = 0 else: l[i] = m - l[i] + 1 print(" ".join(map(str, l)))
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int n; vector<long long> a, b; long long q, max_et; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%I64d", &q); a.push_back(q); } b.push_back(0); max_et = a[n - 1]; for (int i = n - 2; i >= 0; i--) { if (a[i] > max_et) { max...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; long long a[N], b[N]; int main() { int n, d; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = 0; } long long maxx = a[n - 1]; for (int i = n - 2; i >= 0; i--) { if (a[i] <= maxx) { b[i] = maxx + 1 - a[i]; ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n], suf[n]; for (int i = 0; i < n; i++) cin >> arr[i]; suf[n - 1] = arr[n - 1]; for (int i = n - 2; i >= 0; i--) { suf[i] = max(arr[i], suf[i + 1]); } for (int i = 0; i < n - 1; i++) { if (suf[i + 1] >= arr[i]) {...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long int n, t; cin >> n; long long int a[n], b[n]; b[n - 1] = 0; for (long long int i = 0; i < n; i++) cin >> a[i]; t = a[n - 1]; for (long long int i = n - 2; i >= 0;...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
buildingsNum = int(raw_input()) firstLine = raw_input().split(" ") buildings = [] for i in range(0, buildingsNum): buildings.append(firstLine[i]) addedFloors = [] addedFloors.append(0) for i in range (len(buildings) - 2, -1, -1): if addedFloors[len(addedFloors) - 1] == 0: a = int(buildings[i + 1]) + 1 - int(build...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n=int(input()) a=map(int,raw_input().split()) i, mh = n-1, a[n-1] while i>=0: if mh<a[i]: mh=a[i] a[i]=0 else: a[i]=mh-a[i] + 1 i-=1 a[n-1]=0 print(" ".join(map(str,a)))
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
# Description of the problem can be found at http://codeforces.com/problemset/problem/581/B n = int(input()) l_n = list(map(int, input().split())) m = 0 l_a = [0 for i in range(n)] for i in range(n): l_a[n - i - 1] = max(0, m + 1 - l_n[n - i - 1]) m = max(m, l_n[n - i - 1]) print(" ".join(str(x) for x in l_a)...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
/* *In the name of Allah the Most Merciful. * Author * Md. Toufiqul Islam * Dept. Of CSE * Ahsanullah University Of Science And Technology */ //package CodeForces; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Scanner; public cla...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; const int N = 100005; int a[N]; int i, j, n; void input() { cin >> n; for (i = 0; i < n; ++i) { cin >> a[i]; } } int ans; void output() { cout << ans << '\n'; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); input(); int b[N]; ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int main() { int a, b[100005], i, j; cin >> a; for (i = 1; i <= a; i++) { cin >> b[i]; } vector<int> v; int maxn = 0; for (i = a; i >= 1; i--) { if (maxn < b[i]) { v.push_back(0); } else if (maxn > b[i]) { v.push_back(maxn - b[i] + 1); ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n=input() a=map(int,raw_input().split()) maxi=0 l=[] for i in xrange(n-1,0,-1): if a[i]>maxi: maxi=a[i] l.append(maxi) copy=l[::-1] for i in xrange(n-1): if a[i]<=copy[i]: print copy[i]-a[i]+1, else: print 0, print 0
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(raw_input()) a = map(int, raw_input().split()) b = [0]*(n) cur_max = a[n - 1] b[n - 1] = 0 for i in xrange(n - 2, -1, -1): if a[i] <= cur_max: b[i] = cur_max - a[i] + 1 cur_max = max(a[i], cur_max) for i in xrange(len(b)): print b[i],
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.util.ArrayList; import java.util.Scanner; public class CodeForces { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i]=sc.nextInt(); } ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; const int N = 100001; const double eps = 1e-11; const int inf = (int)2e9; const int mod = (int)1e9 + 7; int a[N]; int s[N]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", a + i); } for (int i = n - 1; i >= 0; i--) { s[i] = m...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; long long n, m = -1000, k, l, i, j, a[110000], b[110000]; int main() { cin >> n; for (i = 1; i <= n; i++) cin >> a[i]; for (i = n; i >= 1; i--) { b[i] = max(m - a[i] + 1, 0ll); m = max(m, a[i]); } for (i = 1; i <= n; i++) cout << b[i] << " "; return 0; }...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.io.InputStreamReader; import java.io.BufferedReader; public class BCF518B { public static void main(String[]args)throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(br.readLine()); int arr[]=new int[n]; int...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(input()) bF = list(map(int, input().split())) max_ahead = [0] for i in range(n - 2, -1, -1): max_ahead.append(max(bF[i + 1], max_ahead[-1])) max_ahead = max_ahead[::-1] for i in range(0, n): if bF[i] > max_ahead[i]: print(0, end=" ") else: print(max_ahead[i] - bF[i] + 1, end=" ")
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; long long mx, n, i, j, a, x, t[100000], v[100000]; int main() { cin >> n; for (i = 0; i < n; i++) cin >> t[i]; v[n - 1] = 0; mx = t[n - 1]; for (i = n - 2; i >= 0; i--) { if (t[i] > mx) { v[i] = 0; mx = t[i]; } else v[i] = mx - t[i] + 1; ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(input()) a = list(map(int, input().split())) b = [] mx = -(10**10) for i in range(n-1, -1, -1): b.append(max(0, mx+1-a[i])) mx = max(mx, a[i]) b = b[::-1] for i in b: print(i, end = ' ')
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[100000], b[100000]; for (int i = 0; i < n; i++) cin >> a[i]; b[n - 1] = 0; int mx = a[n - 1]; for (int i = n - 2; i >= 0; i--) { if (a[i] > mx) { mx = a[i]; b[i] = 0; } else b[i] = 1 + mx - a[i]; ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.r...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
from itertools import imap I = lambda: map(int, raw_input().split()) n, = I() houses = I()[:n] _max = 0 lux = [0] * n for index in range(n-1, -1, -1): if houses[index] <= _max: lux[index] = _max + 1 else: _max = houses[index] lux[index] = _max print ' '.join(imap(lambda x, y: str(x - y)...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int MOD = 1e9 + 7; const int maxn = 1e6 + 10; const int maxv = 1e3 + 10; const double eps = 1e-9; inline int read() { char c = getchar(); int f = 1; while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } int x = 0; ...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
# https://vjudge.net/contest/379796#problem/M n=int(input()) z=list(map(int,input().split())) lst=[0]*n;m=z[-1];lst[-1]=0 for i in range(n-2,-1,-1): if z[i] > m: lst[i]=0 m = z[i] else: lst[i]= m-z[i]+1 print(*lst)
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
n = int(input()) a = [int(s) for s in input().split()] b = [0]*n i = n-1 sum = 0 while i > 0: sum = max(sum, a[i]) b[i-1] = max(0, sum + 1 - a[i-1]) i = i - 1 for elem in b: print(elem, end=' ')
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
import sys import math #import random #sys.setrecursionlimit(1000000) input = sys.stdin.readline ############ ---- USER DEFINED INPUT FUNCTIONS ---- ############ def inp(): return(int(input())) def inara(): return(list(map(int,input().split()))) def insr(): s = input() return(list(s[:len(s) - 1])) def...
Problem: The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater th...
#include <bits/stdc++.h> using namespace std; int const N = 1e6 + 5; int n, m, arr[N], b[N], cnt = 0, ma; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } ma = arr[n]; for (int i = n - 1; i >= 0; i--) { if (ma < arr[i]) { ma = arr[i]; continue; } else { b[i] ...