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() {
int no_of_houses;
cin >> no_of_houses;
vector<int> floors;
vector<int> lux_floors;
int max_height = 0;
int temp;
for (int i = 0; i < no_of_houses; i++) {
cin >> temp;
floors.push_back(temp);
}
for (int i = no_of_houses - 1; i >= 0; i--... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 |
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Bit... | 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;
int arr[(int)1e5 + 5];
int m[(int)1e5 + 5];
int main() {
ios_base::sync_with_stdio(false);
cin >> N;
for (int i = 0; i < N; i++) cin >> arr[i];
for (int i = N - 1; i >= 0; i--) m[i] = max(arr[i], m[i + 1]);
for (int i = 0; i < N; i++) {
if (arr[i] > m[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 | #In the name of God
n = int(raw_input())
arr = map(int, raw_input().split())
maxx = [0 for i in range(n)]
build = [0 for i in range(n)]
maxx[-1] = arr[-1]
for i in range(n-2, -1, -1):
maxx[i] = max(arr[i+1], maxx[i+1])
build[i] = 0 if arr[i] > maxx[i] else maxx[i]-arr[i]+1
print ' '.join(map(str, build))
| 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 = [int(x) for x in input().split()]
b = [0] * n
for i in range(n - 2, -1, -1):
b[i] = max(b[i + 1], a[i + 1])
print(' '.join(str(max(0, x - y + 1)) for x, y in zip(b, a)))
| PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
map<int, int> mm;
int main() {
int i, j, n;
cin >> n;
int a[n];
vector<int> res;
for (i = 0; i < n; i++) {
cin >> a[i];
}
int mx = -1;
for (i = n - 1; i >= 0; i--) {
mx = max(mx, a[i]);
mm[mx]++;
if (mx == a[i] && mm[mx] == 1)
res.push_... | 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 bb {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int[] l = new int[num];
int max = 0;
for (int i=0;i<num;i++) {
l[i] = sc.nextInt();
}
int[] ans = new int[num];
for (int i=num-1;i>-1;i--) {
if (l[... | 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;
inline int rit() {
int x;
scanf("%d", &x);
return x;
}
int n;
int a[100005], ans[100005];
void read() {
int i, d;
n = rit();
for (i = 0; i < n; i++) a[i] = rit();
d = a[n - 1] + 1;
ans[n - 1] = 0;
for (i = n - 2; i >= 0; i--) {
ans[i] = max(0, d - 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.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.String.*;
public class Main {
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 | #include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k, t, s, x, y, h[100005], hh[100005], d, l;
int main() {
cin >> n;
for (i = 0; i < n; i++) scanf("%d", h + i);
m = h[n - 1];
for (i = n - 2; i >= 0; i--) {
if (h[i] <= m)
hh[i] = m - h[i] + 1;
else
m = h[i];
}
for (i = 0; i < ... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.util.*;
public class LuxuriousHouses {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)a[i]=sc.nextInt();
int ans[]=new int[n];
int max=a[n-1];
for(int i=n-2;i>=0;i--) {
if(a[i]>max) {
max=a[i];
... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.util.Scanner;
public class LuxuriousHouses {
static Scanner sc = new Scanner(System.in);
public static void main(String args[]) {
int n = sc.nextInt();
int[] t = new int[n];
int[] tab = new int[n];
for (int i = 0; i < n; i++)
t[i] = sc.nextInt();
tab[n - 1] = 0;
int max = t[n - 1];
f... | 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 | z=int(input())
x=list(map(int,input().split()))
x.reverse()
f=x[0]
d=[]
for i in range(z):
if f>=x[i] and i!=0:
d.append(str(f-x[i]+1))
elif f==x[i]:
d.append("0")
elif f<x[i]:
d.append("0")
f=x[i]
d.reverse()
print(" ".join(d).strip())
| 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 org.omg.Messaging.SYNC_WITH_TRANSPORT;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Houses {
public static void main(String... args) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
... | 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[100009];
pair<int, int> ma[100009];
cin >> n;
stack<int> s;
for (int i = 1; i <= n; i++) cin >> a[i];
ma[n].first = a[n], ma[n].second = n;
for (int i = n - 1; i > 0; i--) {
if (a[i] > ma[i + 1].first) {
ma[i].first = 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.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class Main{
public stati... | 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 | /**
* Created by InfoLight on 10/3/2015.
*/
import java.util.Scanner;
public class Main {
public static long max(long a, long b){
if (a > b) return a;
else return b;
}
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int totalCount = Integ... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n=int(input())
a=list(map(int,input().split()))
flag=0
b=[0]
k=a[-1]
for i in range(1,n):
if k>a[n-i-1]:
b.append(-a[n-i-1]+k+1)
else:
if k-a[n-i-1]+1>0:
b.append(k-a[n-i-1]+1)
else:
b.append(0)
k=a[n-i-1]
for i in b[::-1]:
print(i,end=' ') | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
void solve() {
int n;
cin >> n;
vector<int> vec(n);
for (int& i : vec) cin >> i;
vector<int> pref(n);
pref[n - 1] = vec[n - 1];
for (int i = (n - 2); i >= 0; i--) {
pref[i] = max(pref[i + 1], vec[i]);
}
vector<int> ans(n);
... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
vector<long long> v(n);
for (long long i = 0; i < n; i++) cin >> v[i];
vector<long long> g(n);
g[n - 1] = v[n - 1];
for (long long i = n - 2; i >= 0; i--) g[i] = max(v[i + 1], g[i + 1]);
for (long long i = 0; i < n - 1; i+... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n;
long long int num[100005], maxn;
int main() {
while (~scanf("%d", &n)) {
for (int i = 0; i < n; i++) scanf("%lld", &num[i]);
maxn = num[n - 1];
num[n - 1] = 0;
for (int i = n - 2; i >= 0; i--) {
if (num[i] <= maxn) {
num[i] = maxn - nu... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args) {
MyScanner sc = new MyScanner();
out = new PrintWriter(new BufferedOutputStream(System.out));
int n=sc.nextInt();
long arr[]=new long[n];
for(int i=0;i<n;i++)
arr[i]=sc.nextLong();
... | 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 = 100100;
pair<int, int> b[maxn];
int ans[maxn], a[maxn];
int main() {
ios::sync_with_stdio(false);
int n, x;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x;
a[i] = x;
b[i] = make_pair(x, i);
}
sort(b, b + n, greater<pair<int, int> >... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
long long a[n];
for (int i = 1; i <= n; i++) cin >> a[i];
int Max = a[n] - 1;
for (int i = n; i >= 1; i--) {
if (a[i] > Max) {
Max = a[i];
a[i] = 0;
} else
a[i] = Max - a[i] + 1;
}
for (int 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 | #include <bits/stdc++.h>
using namespace std;
int A[100005];
int ans[100005];
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i++) cin >> A[i];
int ma = 0;
for (int i = N - 1; i >= 0; i--) {
ans[i] = max(0, ma - A[i] + 1);
ma = max(ma, A[i]);
}
for (int i = 0; i < N; i++) cout << ans[i] << " ... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class ProblemB {
public static void main(String[] args) {
InputReader in = new InputReader();
PrintWriter out = new PrintWriter(System.ou... | 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 MAX = 100005;
long long a[MAX], b[MAX];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
long long max = a[n - 1];
b[n - 1] = 0;
for (int i = n - 2; i >= 0; i--) {
if (a[i] > max) {
max = a[i];
b[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 | l=int(input())
c=list(map(int,input().split()))
m=[0]
for i in range(l-1,-1,-1):
m.append(max(c[i],m[l-1-i]))
for i in range(l):
if (m[l-1-i]<c[i])or(i==l-1):
print(0,end=' ')
else:
print(m[l-1-i]+1-c[i],end=' ')
| PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 |
import java.util.Scanner;
public class PB {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Communication S=new Communication();
int n=S.i();
int[] a=S.is();
int M=0;
for(int i=n-1;i>-1;i--){
if(a[i]>M){
M=a[i];
a[i]=0;
}else{
... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long double pi = 3.1415926535;
long long num_generator() { return rand() % 1000; }
void array_generator(long long a[], long long n) {
for (long long i = 0; i < n; i++) a[i] = rand() % 100;
}
void solve() {
long long n;
cin >> n;
long long... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import itertools
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
m = a[-1]
for i in range(n - 2, -1, -1):
b[i] = max(0, m - a[i] + 1)
m = max(m, a[i])
print(' '.join(map(str, b)))
| PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int A[n], B[n];
for (int i = 0; i < n; i++) {
cin >> A[i];
}
int max = A[n - 1];
B[n - 1] = 0;
for (int i = n - 2; i >= 0; i--) {
if (max < A[i]) {
max = A[i];
B[i] = 0;
} else {
B[i] = max - A[i] +... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = int(input())
arr = [int(i) for i in input().split()]
stack = []
res = [0 for _ in range(n)]
for i in range(n-1, -1, -1):
if (stack and stack[-1] >= arr[i]):
res[i] = stack[-1] - arr[i] + 1
if (not stack):
stack.append(arr[i])
elif (stack[-1] < arr[i]):
stack.append(arr[i])
pri... | 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 | if __name__ == '__main__':
n = int(raw_input())
heights = [int(num) for num in raw_input().split()]
max_height, adds = 0, [0]*n
for i in reversed(range(n)):
if heights[i] <= max_height:
adds[i] = max_height - heights[i] + 1
max_height = max(heights[i], max_height)
prin... | 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.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
public class j_luxurious_houses
{
static class Reader
{
final private int BUFFER_SIZE = 1 << 16;
private ... | 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())
mass1 = list(map(int,input().split()))
maxx = 0
mass2 = []
for i in range(n - 1, -1, -1):
if mass1[i] > maxx:
mass2.append(0)
maxx = mass1[i]
else:
mass2.append(maxx - mass1[i] + 1)
for i in range(n - 1, -1, -1):
print(mass2[i], end=' ') | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class LuxuriousHouses {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(bf.readLine());
long[] house... | 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()
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 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Houses {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(in.readLine());
String[] temp = in.rea... | 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 long long INF = 1e11 + 5;
const int MAX = 1e5 + 10;
int arr[MAX], answer[MAX];
int main() {
int t;
scanf("%d", &t);
for (int i = 0; i < t; ++i) scanf("%d", &arr[i]);
int ttl = -1;
for (int i = t - 1; i >= 0; --i) {
if (arr[i] > ttl)
answer[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 | n = int(input())
h = [int(i) for i in input().split()]
maxHeight = h[-1]
heightRequired = [0]
for i in range(len(h)-2, -1, -1):
heightRequired.append(max(0, maxHeight - h[i] + 1))
maxHeight = max(maxHeight, h[i])
heightRequired.reverse()
for i in range(len(heightRequired)):
print(heightRequired[i], end = " ... | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
const long long INF = 2e9;
const long long N = 1e5 + 1;
const long long mod = 1e9 + 7;
const long double eps = 1E-7;
using namespace std;
bool used[10001];
void solve() {
int n, a[N];
vector<int> v;
cin >> n;
for (int i = 0; i < n; ++i) cin >> a[i];
int mx = 0;
for (int i = n - 1; i... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = int(input())
h = list(map(int, input().split()))
m_h = 0
res = []
for h in h[::-1]:
if m_h < h:
res.append(0)
m_h = h
else:
res.append(m_h - h + 1)
print(" ".join(map(str, res[::-1]))) | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
void swapll(long long *a, long long *b) {
long long tmp = *a;
*a = *b;
*b = tmp;
}
void swapc(char *a, char *b) {
char tmp = *a;
*a = *b;
*b = tmp;
}
void solve() {
long long n;
cin >> n;
vector<long long> v(n);
for (long long i = 0; i < n; i++) cin >> v... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModu... | 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 | //package Codeforces;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;
/**
* Created by mudi... | 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 | /* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner s = ne... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
template <class T>
T power(T N, T P) {
return (P == 0) ? 1 : N * power(N, P - 1);
}
int main() {
long long int n;
long long int ara[100100];
cin >> n;
long long int boro = -1;
long long int maxi[100100];
memset(maxi, -1, sizeof maxi);
for (long long int i = ... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 |
//package solution;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Solution implements Runnable {
BufferedReader in;
P... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long int n, a[100005], m, s, x, y, z;
string k;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = n; i > 0; i--) {
if (a[i] > m)
z = 0;
else
z = 1;
m = max(a[i], m);
a[i] = m - a[i] + z;
}
for ... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
int main() {
long long n, max, i;
scanf("%lld", &n);
long long a[n], b[n];
for (i = 0; i < n; i++) scanf("%lld", &a[i]);
b[n - 1] = 0;
max = a[n - 1];
for (i = n - 2; i >= 0; i--) {
if (max >= a[i]) {
b[i] = max - a[i] + 1;
} else if (max < a[i]) {
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 x;
int main() {
scanf("%i", &x);
int *A1 = new int[x];
for (int i = 0; i < x; i++) scanf("%i", &A1[i]);
int mx = A1[x - 1], sum = 0;
vector<int> A2;
A2.push_back(0);
for (int i = x - 2; i > -1; i--) {
A2.push_back(max(0, mx - A1[i] + 1));
mx = max(... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, h, m, mx;
vector<int> vp;
cin >> n;
m = n;
while (n--) {
cin >> h;
vp.push_back(h);
}
mx = vp[m - 1];
vp[m - 1] = 0;
for (int i = m - 2; i >= 0; i--) {
if (vp[i] <= mx)
vp[i] = mx - vp[i] + 1;
else if (vp... | 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.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author Tifuera
*/
public class Main {
public static void main(Strin... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n=int(input())
l=list(map(int,input().split()))
v=0
S=[]
for i in range(n-1,-1,-1) :
if l[i]<=v :
S.append(abs(l[i]-v)+1)
else :
S.append(0)
if l[i]>v :
v=l[i]
S1=[]
for i in range(n-1,-1,-1) :
S1.append(str(S[i]))
print(' '.join(S1))
| PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.util.*;
import java.io.*;
public class Solution{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken())... | 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 | if __name__ == '__main__':
n = int(input())
l = list(map(int, input().split()))
a = []
max1 = 0
for i in range (n-1,-1,-1):
if l[i] > max1 :
max1 = l[i]
a.append(0)
else:
a.append((max1-l[i])+1)
a.reverse()
print(*a) | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author Erasyl Abenov
*
*
*/
pub... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.util.*;
public class bucky{
public static void main (String args[]) {
Scanner input=new Scanner(System.in);
HashMap<Integer, Integer> map= new HashMap<Integer, Integer>();
int n=input.nextInt();
Long nums[]=new Long[n];
Long valori[]=new Long[n];
Long max=Long.valueOf(-1);
for (int ... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long a[100005];
int main() {
int N;
scanf("%d", &N);
for (int i = 1; i <= N; ++i) scanf("%ld", &a[i]);
long maxi = INT_MIN;
for (int i = N; i >= 1; --i) {
if (a[i] > maxi) {
maxi = a[i];
a[i] = 0;
} else if (a[i] < maxi) {
a[i] = maxi - a... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, mx = 0;
cin >> n;
vector<long long> v(n), v2(n);
if (n == 1) {
cout << 0;
return 0;
}
for (int i = 0; i < n; i++) {
cin >> v[i];
}
mx = v[n - 1];
v2.push_back(0);
for (int i = n - 2; i >= 0; i--) {
if (v[i] - mx ... | 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.math.*;
public class Div2_322_B {
public static void main(String[] args) throws IOException {
BufferedInputStream bis = new BufferedInputStream(System.in);
BufferedReader br = new BufferedReader(new InputStreamReader(bis));
int n = Integer.parseInt(br.readLine()... | 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 i, j, a[100005], b[100005], n, s, sm;
cin >> n;
for (i = 0; i < n; i++) cin >> a[i];
sm = 0;
for (i = n - 1; i >= 0; i--) {
b[i] = sm;
if (a[i] > sm) sm = a[i];
}
for (i = 0; i < n; i++) {
if (a[i] <= b[i])
cout << b[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 = int(raw_input())
r = raw_input()
l = r.split(' ')
l.reverse()
L = []
highest = 0
for y in l:
x = int(y)
if x > highest:
highest= x
L.append('0')
else:
L.append(str(highest-x+1))
L.reverse()
print ' '.join(L) | PYTHON |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class CF_322_B {
public static void main(String[] args) throws IOException{
PrintWriter pw = new PrintWriter(System.out, true);
BufferedReader input = new BufferedReader(... | 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()))
R = ["" for _ in range(n)]
R[n-1] = "0"
m = L[n-1]
for k in range(n-2,-1,-1):
if m >= L[k]:
R[k] = str(m-L[k]+1)
else:
R[k] = "0"
m = max(L[k],m)
print(" ".join(R))
| PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n + 1], i, g;
for (i = 1; i <= n; ++i) cin >> a[i];
g = a[n];
for (i = n - 1; i > 0; --i) {
if (a[i] > g) {
g = a[i];
a[i] = 0;
} else if (a[i] <= g) {
a[i] = (g + 1 - a[i]);
}
}
a[n] = 0;
f... | 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;
inline double min(double a, double b) {
if (a < b) return a;
return b;
}
int n;
int arr[100010];
int dp[100010];
int main() {
cin >> n;
for (int(i) = (0); (i) < (n); i++) cin >> arr[i];
dp[n - 1] = 0;
for (int i = n - 2; i >= 0; i--) {
dp[i] = max(arr[i + 1]... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n=int(input())
a=list(map(int,input().split()))
b=(n-1)
c=[]
c.append(0)
for i in range(n-2,-1,-1):
if a[i]<=a[b]:
c.append(a[b]-a[i]+1)
else:
b=i
c.append(0)
print(*c[::-1])
| PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e5 + 10;
long long n, a[MAX];
long long Max[MAX];
int main() {
cin >> n;
for (long long i = 1; i <= n; i++) cin >> a[i];
Max[n] = a[n];
for (long long i = n - 1; i >= 1; i--) {
if (a[i] > Max[i + 1])
Max[i] = a[i];
else
Max... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
int n, maxf;
cin >> n;
int h[n];
for (int i = 0; i < n; i++) cin >> h[i];
maxf = h[n - 1];
h[n - 1] = 0;
for (int i = n - 2; i >= 0; i--) {
if (h[i] > maxf) {
maxf = h[i];
h[i] = 0;
} else
h[i]... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i, c = 0;
scanf("%i", &n);
vector<int> b(n), a(n);
for (i = 0; i < n; i++) scanf("%i", &b[i]);
for (i = b.size() - 1; i >= 0; c = max(c, b[i--]))
a[i] = max(0, c + 1 - b[i]);
for (int i = 0; i < n; i++) printf("%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 | #include <bits/stdc++.h>
using namespace std;
int n, Max, a[100005], b[100005];
int main() {
cin >> n;
for (int i = 0; i < n; ++i) cin >> a[i];
for (int i = n - 1; i >= 0; i--) {
b[i] = max(0, Max - a[i] + 1);
Max = max(Max, a[i]);
}
for (int i = 0; i < n; ++i) cout << 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 | import java.util.*;
public class solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] a=new int[n];
for(int i=0;i<n;i++) {
a[i]=sc.nextInt();
}
int max=Integer.MIN_VALUE;
int ans[]=new int[n];
for(int i=n-1;i>=0;i--) {
if(a[i]>max) {
... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | N = int(input())
H = list(map(int, input().split()))
maxh = H[-1]
maxlst = []
for i in range(N):
maxh = max(maxh, H[N - i - 1])
maxlst.append(maxh)
maxlst.reverse()
ans = []
for i in range(N):
if i == N - 1:
a = 0
else:
maxv = maxlst[i + 1]
if H[i] == maxv:
a = 1
... | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class CFLuxHouse {
public static void main(String[] args)throws IOException {
// TODO Auto-generated method stub
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
in... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 |
import java.util.Scanner;
public class B321 {
public static void main(String[] args) {
int n;
Scanner in=new Scanner(System.in);
n=in.nextInt();
int[] a=new int[n];
int[] b=new int[n];
for(int i=0;i<n;i++){
a[i]=in.nextInt();
}
int m=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.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] h = new int[n];
for (int i = 0; i < h.length; i++) {
h[i] = sc.nextInt();
}
System.out.println(String.join(" ", Arrays.stream... | 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 ar[n], ans[n];
for (int i = 0; i < n; i++) cin >> ar[i];
int maxi = 0;
for (int i = n - 1; i >= 0; i--) {
ans[i] = max(maxi - ar[i] + 1, 0);
maxi = max(maxi, ar[i]);
}
for (int i = 0; i < n; i++) cout << ans[i] << " ... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.util.*;
import java.io.*;
import java.util.Scanner;
public class main {
public static void main (String [] args) throws Exception {
new main();
}
BufferedReader in;
PrintWriter out;
StringTokenizer st;
public String next() throws Exception { //takes next word from input
if (st == null || !st.... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long nn[100010];
bool bb[100010];
long long maxx[100010];
int main() {
int n;
while (scanf("%d", &n) != EOF) {
memset(bb, 0, sizeof(bb));
memset(nn, 0, sizeof(nn));
memset(maxx, -1, sizeof(maxx));
for (int i = 0; i < n; i++) {
scanf("%I64d", &... | 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
raw_input()
houses = [int(i) for i in raw_input().strip().split(" ")]
N = len(houses)
maxh = 0
rs = [0] * N
for i in xrange(N-1, -1, -1):
# print i
h = houses[i]
if maxh < h:
maxh = h
r = 0
else:
r = maxh + 1 - h
rs[i] = str(r)
print " ".join(rs)
| PYTHON |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n + 1];
a[n] = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
vector<int> res;
for (int i = n - 1; i >= 0; --i) {
res.push_back(max(0, a[i + 1] - a[i] + 1));
a[i] = max(a[i], a[i + 1]);
}
for (int i = n - ... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int a[100020];
long long b[100020];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
long long max = a[n - 1];
for (int i = n - 2; i >= 0; i--) {
if (a[i] <= max)
b[i] = max - a[i] + 1;
else
max = a[i];
}
for (int i = ... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #!/usr/bin/env python
#-*- coding: utf-8 -*-
def main_fun():
n = int(raw_input().strip())
line = raw_input().strip().split(' ')
d = {n-1:0}
for x in range(n-2,-1,-1):
if int(line[x+1]) > d[x+1]:
d[x] = int(line[x+1])
else:
d[x] = d[x+1... | PYTHON |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n=input()
l=[int(i) for i in raw_input().split()]
m=-1000000007
k=[]
for i in range(n-1,-1,-1):
x=l[i]
if x>m:
m=x
k.append(0)
else:
k.append(m+1-x)
for i in range(n):
print k.pop(), | 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.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.util.*;
import java.io.*;
import java.util.stream.*;
public class b {
private void solve() throws IOException {
int n = nextInt();
Integer[] a = new Integer[n];
for(int i = 0; i < n; ++i) {
a[i] = nextInt();
}
int curMax = 0;
for(int i = n -... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long power(long long a, long long b) {
long long ret = 1;
while (b) {
if (b % 2 == 1) ret = (ret * a) % ((int)(1e9) + 7);
b /= 2;
a = (a * a) % ((int)(1e9) + 7);
}
return... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int sol[n];
fill(sol, sol + n, 0);
int mx = a[n - 1];
sol[n - 1] = 0;
for (int i = n - 2; i >= 0; i--) {
if (a[i] <= mx) {
sol[i] = mx + 1 - a[i];
}
... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | //Author: Mo Abjal, MJP Rohilkhand University Bareilly, UP, India 2018.
///////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////********************//////////////////////////////////////////////
////////////////////////////////... | 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 | var numeric = readline(),
floor = readline().split(' '),
result = [0];
for (; floor.length; ) {
var last_floor = +floor[floor.length - 1],
prev_floor = +floor[floor.length - 2];
if (prev_floor > last_floor) {
result.unshift(0);
floor.splice(floor.length - 1, 1);
} else {
if (last_floor === prev_floor... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n;
cin >> n;
long long int a[n], b[n], max = 0;
b[n - 1] = 0;
for (long long int i = 0; i < n; i++) cin >> a[i];
for (long long int i = n - 1; i >= 0; i--) {
if (i == n - 1)
max = a[i];
else {
if (a[i] <= max) {
... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n, houses = int(raw_input()), map(int, raw_input().split())
m, l = houses[n-1], [0]
for i in xrange(n-2, -1, -1):
l.append(0 if houses[i] > m else m + 1 - houses[i])
m = max(m, houses[i])
print ' '.join(map(str, reversed(l)))
| 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 B581 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
int max = a[n-1];
int[] add = new int[n];
for (int i = n-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 | input()
a=map(int,raw_input().split())
r,m=[],0
for d in a[::-1]:
r+=max(m+1-d,0),
m=max(m,d)
for d in r[::-1]:
print d,
| 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(raw_input().strip())
houses = map(int, raw_input().strip().split(' '))
answers = [-1] * n
maxfloors = -1
for i in xrange(len(houses) - 1, -1, -1):
answers[i] = max(maxfloors + 1 - houses[i], 0)
if houses[i] > maxfloors:
maxfloors = houses[i]
print ' '.join(map(str, answers)) | PYTHON |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 20;
int a[MAXN], ans[MAXN];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, maximum = 0;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
ans[n - 1] = 0, maximum = max(maximum, a[n - 1]);
for (int i = n... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> v;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
v.push_back(a);
}
int Max = v.back();
v.back() = 0;
for (int i = v.size() - 2; i >= 0; i--) {
if (v[i] < Max)
v[i] = ((Max - v[i]) + 1);
els... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int arr[100000 + 7], mx, d, ans[100000 + 7], n, i, j, k;
while (scanf("%lld", &n) == 1) {
for (i = 1; i <= n; i++) {
scanf("%lld", &arr[i]);
}
mx = 0;
for (i = n; i > 0; i--) {
if (arr[i] > mx) {
mx = arr[i];
... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.