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; int main() { long long n; cin >> n; long long p[n], q[n]; for (long long i = 0; i < n; i++) { cin >> p[i]; } long long m = p[n - 1]; for (long long i = n - 2; i >= 0; i--) { if (p[i] <= m) { q[i] = (m - p[i]) + 1; } else { q[i] = 0; ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class LuxuriousHouses { void solve() { int n = in.nextInt(); int[] H = new int[n]; for (int 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 main() { int n, *a; cin >> n; a = new int[n]; for (int i = 0; i < n; i++) cin >> a[i]; int mx = a[n - 1]; vector<int> v; v.push_back(0); for (int i = n - 2; i >= 0; i--) { mx = max(mx, a[i + 1]); v.push_back(max(mx - a[i] + 1, 0)); } for (int...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import math def fact(n): ans = 1 for i in range(2, n+1): ans*= i return ans def comb(n, c): return fact(n)//(fact(n-c)*c) n = int(input()) nums= list(map(int, input().split())) m= 0 ans = [] for i in range(n-1, -1, -1): if(nums[i] <= m): ans.append(str(m-nums[i]+1)) else: ...
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#!/bin/python from sys import stdin n=int(stdin.readline().strip()) arr=map(int,stdin.readline().strip().split()) max=arr[n-1]+1 ans=[0]*n for i in range(n-2,-1,-1): if arr[i]<max: ans[i]=max-arr[i] else: ans[i]=0 max=arr[i]+1 for i in range(n): print ans[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()) mas = list(map(int,input().split(" "))) submas=[0]*(n) ma=0 for i in range(n-1,-1,-1): submas[i]=str(max(ma-mas[i]+1,0)) if (ma<mas[i]): ma =mas[i] print(" ".join(submas))
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 long long MAXN = (long long)((1e5) + 100); long long cuberoot(long long x) { long long lo = 1, hi = min(2000000ll, x); while (hi - lo > 1) { long long mid = (lo + hi) / 2; if (mid * mid * mid < x) { lo = mid; } else hi = mid; } if (hi *...
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()) out = [0]*n m = 0 for i in range(n) : e = a[n-1-i] if e <= m : out[n-1-i] = m - e + 1 else : m = e for o in out: print o,
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
__author__ = 'yarsanich' n = int(input()) a = list(map(int,input().split())) 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)
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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class B { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); 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
import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.InputMismatchException; public class Main { class MyScanner { private byte[] buf = new byte[1024]; private int curChar; private int numChars; BufferedInputStream bis = new BufferedInpu...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.*; import java.util.ArrayList; import java.util.StringTokenizer; /** * Created by tawsif on 9/29/15. * * @Time 12:07 PM */ public class LuxuriousHouses322B { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; PrintWriter out; long timeBegin, timeEnd; public void runIO() th...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.*; import java.util.*; public class B { public static void main(String[]args)throws IOException{ BufferedReader x=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(x.readLine()); StringTokenizer st=new StringTokenizer(x.readLine()); int[]arr...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
i = int(input()) l = list(reversed(list(map(int,input().split())))) m = 0 t = [] for x in l: if x > m: t.append(0) else: t.append((m+1) - x) if x > m: m = x print(' '.join([str(elem) for elem in list(reversed(t))]))
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 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; ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.Scanner; public class B_581 { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub Scanner sc ...
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()] + [0] v = [0 for i in h] for p in range(n,-1,-1): if p == n: v[p] = h[p] else: v[p] = max(v[p+1], h[p]) print(' '.join(["%s" % max(0, v[i+1]+1-h[i]) for i in range(n)]))
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, a[100002], m[100002], i, j, ans[100002]; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &a[i]); } m[n - 1] = 0; ans[n - 1] = 0; for (i = n - 2; i >= 0; i--) { m[i] = max(m[i + 1], a[i + 1]); ans[i] = max(0, m[i] - 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 = input() h = map(int, raw_input().split()) maxvec = [ 0 for i in xrange(n)] for i in xrange(n-2,-1,-1): maxvec[i]=max(maxvec[i+1],h[i+1]) newh=[max(maxvec[i]-h[i]+1,0) for i in xrange(n)] for i in newh: print i,
PYTHON
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.*; import java.io.*; public class temp { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] arr = new int[n]; StringTokenizer st = new StringTokenizer(br.r...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6; const int MAX = 1e7 + 1; double pi = 3.1415926535897932384626433832795; const long long inf = 1e18; long long mod = 1e6; long long powr(long long a, long long b) { if (b == 0) return 1LL; long long x = powr(a, b / 2); x = (x * x) % mod; if (b %...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.*; import java.io.*; public class solution { public static void merge(long arr[], int l, int m, int r) { // Find sizes of two subarrays to be merged int n1 = m - l + 1; int n2 = r - m; /* Create temp arrays */ long L[] = new long[n1]; long R[] = new...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; impor...
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 B { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int n = cin.nextInt(); int[] a = new int[n]; int[] max = new int[n]; boolean[] visited = new boolean[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()) l = list(map(int , input().split())) a = list(range(n+1)); y = 0 for i in range(n-1 , -1 , -1): y = max(y , l[i]) a[i] = y a[n] = 0 for i in range(n): if (l[i] == a[i]) & (l[i] != a[i+1]): print('0 ' , end = '') else: print(a[i]-l[i]+1 , end = '') print(' ' , end...
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.Scanner; public class LuxuriousHouse { public static void main(String asd[])throws Exception { Scanner in=new Scanner(System.in); int n=in.nextInt(); int a[]=new int[n]; int b[]=new int[n]; int max=Integer.MIN_VALUE;int k=0; for(int i=0;i<n;i++)...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.*; import java.util.*; public class div_2_322_b { public static void main(String args[]){ FScanner in = new FScanner(); PrintWriter out = new PrintWriter(System.out); //int t = in.nextInt(); //while(t-->0) { } int n=in.nextInt(); int a[]=in.readArray(n); int arr[]=new int[n]; int max=0;...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class LuxuriousHouses { public static void main(String[] args) { out = new PrintWriter(new BufferedOutputStream(Syst...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
input() h = list(map(int,input().split())) m = h[-1] n = [] for x in h[::-1]: n.append(str(max(0,m-x))) m = max(m,x+1) print (' '.join(n[::-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(void) { int total; cin >> total; int *input = new int[total]; int *save = new int[total]; for (int i = 0; i < total; i++) cin >> input[i]; save[total - 1] = 0; int highest = input[total - 1]; for (int i = total - 2; i > -1; i--) { if (input[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()) l=[int(i) for i in input().split()] l.reverse() n1=1 ans=[0] mx=l[0] if n>1: if l[0]<l[1]: ans.append(0) else: ans.append(l[0]-l[1]+1) while n1<n-1: num1=l[n1] num2=l[n1+1] mx=max(num1,l[0],mx) if num2<=mx: ans.append(mx-num2+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.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author karanjobanputra */ public ...
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; template <typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; } template <typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; } int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } i...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.Scanner; public class LuxuriousHouses { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int arr[] = new int[n]; int ans[] = new int[n]; int max = 0; 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()) t = list(map(int,input().split()))[::-1] f=[0] u=t[0] for k in range(1,n): if t[k]>u: f.append(0) if t[k]>u: u=t[k] else: s = u-t[k]+1 f.append(s) if t[k]>u: u=t[k] print(*f[::-1])
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n=int(input()) l=list(map(int,input().split())) max1=0 arr1=[] for i in range (n-1,-1, -1): if l[i] >max1: max1=l[i] arr1.append(0) elif l[i]==max1: arr1.append(1) else: arr1.append(max1-l[i]+1) arr1=arr1[::-1] print(*arr1)
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[i]; } int max = v[v.size() - 1]; vector<int> res; res.push_back(0); for (int i = v.size() - 2; i >= 0; i--) { if (max >= v[i]) { res.push_back(max - v[i] +...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = input() buildings = list(map(int, input().split(' '))) m = 0 result = [] for i in range(len(buildings) - 1, -1, -1): b = buildings[i] x = m - b if x < 0: result.append(0) m = b else: result.append(x + 1) print(' '.join(map(str, result[::-1])))
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { long long r; while (b != 0) { r = a % b; a = b; b = r; } return a; } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } const int maxn = 100010; int n; int h[maxn]; int ans[maxn]; void solve() ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import sys input=sys.stdin.buffer.readline n=int(input()) arr=list(map(int,input().split())) right_max=arr[n-1] ans=[0] for i in range(n-2,-1,-1): if arr[i]>right_max: ans.append(0) right_max=arr[i] else: ans.append(right_max-arr[i]+1) ans=ans[::-1] for x in ans: print(x,end=' ') #unknown_2433
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int a[100001], maxi[100001]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = n - 1; i >= 0; i--) { maxi[i] = max(maxi[i + 1], a[i]); } for (int i = 0; i < n; i++) { cout << max(maxi[i + 1] - a[i] + 1, 0) << '...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.Scanner; public class _0909LuxuriousHouses { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); long[] arr = new long[n]; for(int i=0;i<n;i++) { arr[i]=sc.nextLong(); } long max=arr[n-1]; arr[n-1]=0; for(int i=n-2;i>=0;i--) { lo...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import time n = int(input()) A = [int(i) for i in input().split()] start = time.time() A = [ A[n-i-1] for i in range(n)] ans = [ 0 for i in range(n) ] m = 0 for i in range(n): if A[i] > m: m = A[i] else: ans[i] = 1+m-A[i] for i in rang...
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int a[100000]; int b[100000]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } int max = a[n - 1]; b[0] = 0; for (int i = n - 2; i >= 0; i--) { if (a[i] <= max) { b[i] = max - a[i] + 1; } else { b[i] = 0; ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v(100000), a(100000); int max = -1, c; cin >> c; for (int i = 0; i < c; i++) { cin >> v[i]; } a[c - 1] = 0; max = v[c - 1]; for (int i = c - 2; i >= 0; i--) { if (v[i] > max) { max = v[i]; a[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
#include <bits/stdc++.h> using namespace std; int n, a[100005], maxx[100005]; int main(void) { int i, j; while (~scanf("%d", &n)) { for (i = 0; i < n; i++) scanf("%d", &a[i]); maxx[n - 1] = 0; for (i = n - 2; i >= 0; i--) maxx[i] = max(maxx[i + 1], a[i + 1]); for (i = 0; i < n; i++) { if (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
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; public class Main { public static void main...
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_base::sync_with_stdio(false); cin.tie(0); int n; int h[100000], max[100001]; cin >> n; for (int i = 0; i < n; ++i) { cin >> h[i]; } max[n] = h[n - 1] - 1; for (int i = n - 1; i >= 0; --i) { if (h[i] > max[i + 1]) max[i] = h[i...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long n, y = 0; cin >> n; long long a[n], b[n]; for (long long i = 0; i < n; i++) { cin >> a[i]; } b[n - 1] = 0; y = a[n - 1]; for (int i = n - 2; i >= 0; i--) { if (y == a[i]) { b[i] = 1; } else { y = max(y, 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
#!/usr/bin/python from collections import deque def ir(): return int(raw_input()) def ia(): line = raw_input() line = line.split() return map(int, line) # e + x = m + 1 # x = m + 1 - e n = ir() a = ia(); a.reverse() m = 0; ans = [] for e in a: ans.append(max(m + 1 - e, 0)) if e > m: m ...
PYTHON
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; long long int maxt(long long int x, long long int y) { return (x > y) ? x : y; } int main() { long long int n; cin >> n; long long int arr[n], i; for (i = 0; i < n; ++i) cin >> arr[i]; long long int ans[n]; ans[n - 1] = arr[n - 1]; for (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
n=int(input()) l=input().split() s=[] for i in range(n): l[i]=int(l[i]) s.append(0) i=0 m=l[n-1] while(i<n): k=n-i-1 if(m>=l[k] and i!=0): s[k]=m-l[k]+1 else: m=l[k] i+=1 for i in range(n): print(s[i])
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; long long int h[n]; for (int i = 0; i < n; i++) { cin >> h[i]; } long long int b[n]; long long int max = 0; for (int j = 0; j < n; j++) { if (j == 0) { max = h[n - j - 1]; b[n - j - 1] = max - 1; } else {...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] array = new int[n]; for (int i = 0; i < n; i++) { array[i] = scan.nextInt(); } int[] temp = new int[n]; temp[n-1]=0; int max = array[n-1]; fo...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.*; import java.io.*; import java.lang.*; public class Luxury { static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { this.strea...
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())) l1=[0]*n; mx=0; ans="" for i in range(n-1,-1,-1): mx=max(mx,h[i]) l1[i]=mx for i in range(n-1): if h[i]>l1[i+1]: ans+="0 " else: ans+=f"{l1[i]-h[i]+1} " ans+='0' print(ans)
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.*; public class Test { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int[] arr = new int[sc.nextInt()]; for(int i = 0; i < arr.length; i++){ arr[i] = sc.nextInt(); } sc.close(); int[] max = new int[arr.length]; for(int i = max.length - 2; 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, i, j, a[100000], k, x, b[100000]; int main() { cin >> n; j = n - 2; b[n - 1] = 0; for (i = 0; i < n; i++) cin >> a[i]; x = a[n - 1]; for (i = n - 2; i >= 0; i--) { if (a[i] <= x) { b[j] = x - a[i] + 1; j--; } else { b[j] = 0; ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; long long int a[n], suf[n]; for (i = 0; i < n; i++) { cin >> a[i]; } suf[n - 1] = 0; for (i = n - 2; i >= 0; i--) { suf[i] = max(a[i + 1], suf[i + 1]); } for (i = 0; i < n; i++) { cout << max(suf[i] - a[i] + 1, ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n=input() l=map(int,raw_input().split()) x=[0]*n maxi=l[-1] for i in xrange(n-2,-1,-1): if l[i]>maxi: maxi=l[i] else: x[i]=maxi-l[i]+1 for i in x: print i,
PYTHON
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = int(input()) a = list(map(int, input().split())) a.reverse() mx = 0 out = [0] * n for i in range(n): out[i] = max(mx + 1, a[i]) - a[i] mx = max(a[i], mx) out.reverse() print(' '.join(map(str, 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()) A = list(map(int, input().split())) B = A[:] for i in range(N-2, -1, -1): if(B[i] < B[i+1]): B[i] = B[i+1] for i in range(0, N - 1): if(A[i] > B[i+1]): print("0",end=" ") else: # print(A[i], end = "----") print(B[i+1] + 1 - A[i], end=" ") print("0")
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; double pi = acos(-1); const int MXN = 1e5 + 5; const long long mod = 1e9 + 7; void printv(vector<long long> v, long long n) { for (long long i = 0; i < n; i++) { cout << v[i] << " "; } } vector<long long> inputv(vector<long long> v, long long n) { for (long long 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())) ans = [0] * n x = a[-1] for i in range(n-2, -1, -1): ans[i] = max(0, x-a[i]+1) x = max(a[i], x) print(*ans)
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int num[100010]; int cop[100010]; int ans[100010]; map<int, int> pic; int cmp(int a, int b) { return a > b; } int main() { int n, flagc = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &num[i]); pic[num[i]]++; cop[i] = num[i]; } sort(cop...
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, m, v = int(input()), 0, [] for x in map(int, reversed(input().split())): v.append(max(0, m - x + 1)) m = max(m, x) print(' '.join(map(str, reversed(v))))
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
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.*; /** * * @author MyPC */ public class _581B_LuxuriousHouses { public static void main(String args[]){ ...
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
def f(l): n = len(l) rl = [0]*n rm = l[-1] for i in range(n-2,-1,-1): rl[i] = max(rm+1-l[i],0) if l[i]>rm: rm = l[i] return rl _ = input() #1e5 l = list(map(int,input().split())) print(*f(l))
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; int a[maxn], b[maxn], c[maxn]; int main() { int n; scanf("%d", &n); for (int i = (1); i <= (n); i++) scanf("%d", &a[i]); b[n + 1] = 0; for (int i = (n); i >= (1); i--) { if (a[i] > b[i + 1]) { b[i] = a[i]; } else { b[i]...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = int(input()) house = list(map(int,input().split(' '))) dos = [0]*n maximum = house[n-1] for i in range(n-2,-1,-1): dos[i]=max(0,maximum-house[i]+1) if house[i]>maximum: maximum=house[i] print(*dos)
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())) maxr = [0 for i in range(n)] result = [0 for i in range(n)] for i in range(n-2, -1, -1): maxr[i] = max(maxr[i+1], a[i+1]) for i in range(n): result[i] = maxr[i] - a[i] + 1 if result[i] < 0: result[i] = 0 print(' '.join(str(r) for r in result))
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, num[100002], i, j, ans[100002], max; cin >> n; for (i = 1; i <= n; i++) scanf("%d", &num[i]); ans[n] = 0; max = 0; for (i = n; i >= 1; i--) { if (max <= num[i]) { max = num[i]; ans[i] = 0; ++max; } else ans[i] ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 1; long long n, i, j, k, m; long long dem = 0, tong = 0, x, y, z, l, r; char k1, k2; long long a[maxn], b[maxn], c[maxn], h[maxn]; long long d[maxn]; string s, s1, s2; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; static const int MAXN = 1e5 + 10; int n; int data[MAXN]; int tail[MAXN]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", data + i); } for (int i = n; i > 0; --i) { tail[i] = max(tail[i + 1], data[i + 1]); } for (int i = 1; i <= n...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
N, X, Answer = int(input()), list(map(int, input().split())), [0] Max = X[-1] for i in X[:N - 1:][::-1]: Answer.append(max(0, Max - i + 1)) Max = max(Max, i) print(*Answer[::-1]) # Come together for getting better !!!!
PYTHON3
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.*; public class test { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; int[] anss = new int[n]; int[] dh = new int[n]; for (int i = 0; i < n; i++) arr[i] = sc.nextInt(); dh[n-1] = 0; anss[n-1]=0; String...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int Arr[n]; for (int i = 0; i < n; ++i) cin >> Arr[i]; int mFl = -1; for (int i = n - 1; i >= 0; --i) { if (Arr[i] > mFl) { mFl = Arr[i]; Arr[i] = 0; } else Arr[i] = (mFl + 1) - Arr[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
r=lambda:map(int,raw_input().split()) n=input() h=r() M=0 a=[] for i in reversed(h): a.append(max(0,(M+1)-i)) M=max(M,i) print ' '.join(map(str,reversed(a)))
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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.InputMismatchException; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Bui...
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.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; using ll = long long int; int arr_min(int arr[], int a, int b) { int min = arr[0]; for (int i = a; i != b; i++) { if (min > arr[i]) min = arr[i]; } return min; } int arr_max(int arr[], int a, int b) { int max = arr[0]; for (int i = a; i != b; i++) { if (...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int h[] = new int[n+2]; for(int i = 0 ; i < n; i++) { h[i] = in.nextInt(); } int max[] = new int[n+2]; max[n] = 0; 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
import java.awt.Point; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.Arr...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v(n), x(n); for (int i = 0; i < n; i++) cin >> v[i]; int mx = 0; for (int i = n - 1; i >= 0; i--) { if (v[i] > mx) { x[i] = 0; mx = v[i]; } else if (v[i] < mx) x[i] = mx + 1 - v[i]; else ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = int(raw_input()) hs = map(int, raw_input().split(' ')) max_h = 0 a = [] for h in hs[::-1]: a.append(0 if h > max_h else max_h + 1 - h) if max_h < h: max_h = h for aa in a[::-1]: print aa,
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 = list(reversed(list(map(int, input().split())))) ans = [0]*(n) highestToTheRight = houses[0] for i in range(1,n): if houses[i] > highestToTheRight: highestToTheRight = houses[i] ans[i] = 0 else: ans[i] = highestToTheRight - houses[i] + 1 print(*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
n = int(input()) A = list(map(int, input().split())) etaj = [0] * n l = len(A) ma = A[-1] for i in range(-2, -l-1, -1): if A[i] > ma: ma = A[i] etaj[i] = 0 """ ma = A[i] if A[i] <= A[i+1]: etaj[i] = etaj[i+1] + A[i+1] - A[i] elif (A[i] > A[i+1]) and (e...
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
#!/usr/bin/env python # # http://codeforces.com/problemset/problem/581/B try: n = int(raw_input()) h = raw_input().split() for i in range(0, n): h[i] = int(h[i]) t = 0 for i in reversed(range(0, n)): if h[i] > t: t = h[i] h[i] = 0 else: h...
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; public class contest_1_2 { public static void main(String[] args) { int n; Scanner cin=new Scanner(System.in); n=cin.nextInt(); int[] array=new int[n]; int[] sol=new int[n]; for(int i=0;i<n;i++) { array[i]=cin.nextInt(); } ...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
n = int(input()) houses = [int(x) for x in input().split(' ')] max_sizes = [0] * n current_max = 0 for i in reversed(range(n)): max_sizes[i] = current_max if houses[i] > current_max: current_max = houses[i] for i in range(n): floors_added = max_sizes[i] - houses[i] + 1 if floors_added < 0: floors_added = 0 i...
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; using namespace std::chrono; template <typename T1, typename T2> void mapped(map<T1, T2> m) { for (auto ite = m.begin(); ite != m.end(); ++ite) { cout << "'" << ite->first << "'" << " : " << ite->second << endl; } } template <typename T1, typename T2> void ...
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 MX = (int)1e6 + 17; const int MOD = (int)1e9 + 7; const long long oo = (long long)1e18 + 7; const int INF = (int)999999999; const int N = (int)1e5 + 17; const int di[4] = {-1, 0, 1, 0}; const int dj[4] = {0, 1, 0, -1}; inline long long IN() { long long x = 0, ch...
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 math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin....
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.*; /** * Created by bobyk on 22/08/15. */ public class Main { public static void main(String[] args) throws IOException { new Main().Run(); } InputReader reader; PrintWriter pw; StringTokenizer stok; private void Run() throws IOException { ...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> int a[100010]; int b[100010]; int main() { int n; scanf("%d", &n); memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); for (int i = 0; i < n; i++) scanf("%d", &a[i]); int max1 = a[n - 1]; for (int i = n - 2; i >= 0; i--) { b[i] = max1 - a[i] + 1; if (b[i] < 0) b[i] = 0; ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) throws FileNotFoundException { /*Read and Write*/ //Scanner in=new Scanner(new FileReader("testA.txt")); //FileWriter fw=new FileWriter("output...
JAVA
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 50; int data[maxn], answer[maxn] = {0}; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; ++i) scanf("%d", &data[i]); int high = data[n - 1]; for (int i = n - 2; i >= 0; --i) { if (data[i] > high) high = data[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
#include <bits/stdc++.h> using namespace std; int main() { int n; long long int a[100006], max; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%lld", &a[i]); } max = a[n - 1]; a[n - 1] = 0; for (int i = n - 2; i >= 0; i--) { if (a[i] <= max) { a[i] = max - a[i] + 1; } else { ...
CPP
581_B. Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
2
8
import java.util.Scanner; public class Program { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner (System.in); int n = Integer.parseInt(sc.nextLine()); int [] kq = new int [n]; String [] tmp = sc.nextLine().split(" "); int max = Integer.parseInt(tmp[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; void pl(long long a) { printf("%lld\n", a); } void pll(long long a, long long b) { printf("%lld %lld\n", a, b); } void plll(long long a, long long b, long long c) { printf("%lld %lld %lld ", a, b, c); } void sss(string s) { cout << s, printf("\n"); } long long string_to_l...
CPP