Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.util.*;
import java.io.*;
/**
* @author Alvex - GoldenReam1503@gmail.com
* Time: 1:41:47 PM
* Date: Nov 18, 2015
*/
public class _581B_Luxurious_Houses
{
private static class Output
{
private final PrintWriter printer;
public void printLine(Object...objects)
{
... | 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 JavaApplication154 {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
int a= sc.nextInt();
int[] b= new int[a];
for(int i=0;i<a;i++){
b[i]=sc.nextInt();
}
int max=b[a-1];
... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | a = int(input())
b = list(map(int, input().split()))
b = b[::-1]
h = 0
g = []
for i in b:
if h < i:
h = i
g.append(0)
elif h == i:
g.append(1)
else:
g.append(h - i + 1)
g = g[::-1]
for i in g:
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 | import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;
public class LuxurioursHouses {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
ArrayList<Integer> houses = new ArrayList<Integer>();
for(int i = 0; i < n; i++){
houses.add(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 | #include <bits/stdc++.h>
using namespace std;
template <class T>
inline void remax(T& A, T B) {
if (A < B) A = B;
}
template <class T>
inline void remin(T& A, T B) {
if (A > B) A = B;
}
string ToString(long long num) {
string ret;
do {
ret += ((num % 10) + '0');
num /= 10;
} while (num);
reverse(ret... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | from itertools import imap
I = lambda: map(int, raw_input().split())
n, = I()
houses = I()[:n]
_max = 0
lux = [0] * n
for i in range(1, n+1):
index = n - i
if houses[index] <= _max:
lux[index] = _max + 1
else:
_max = houses[index]
lux[index] = _max
print ' '.join(imap(lambda x, y: s... | 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.lang.*;
import java.io.*;
public class Main
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new InputStreamReader(System.in));
}
String 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 | import java.io.*;
import java.util.StringTokenizer;
/**
* 581B
* ΞΈ(n) time
* ΞΈ(n) space
*
* @author artyom
*/
public class _581B implements Runnable {
private BufferedReader in;
private StringTokenizer tok;
private Object solve() throws IOException {
int n = nextInt();
int[] a = read... | 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 | # -*- coding: utf-8 -*-
"""
Created on Thu Aug 13 23:52:16 2020
@author: DELL
"""
n=int(input())
h=list(map(int,input().split()))
h.reverse()
s=[]
m=0
for i in h:
if i>m:
m=i
a=0
elif m >=i:
a=(m-i)+1
s+=[str(a)]
s.reverse()
print(' '.join(s)) | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> h(N);
for (int i = 0; i < h.size(); ++i) {
cin >> h[i];
}
vector<int> res(N);
int tallest = -1;
for (int i = h.size() - 1; i >= 0; --i) {
if (h[i] <= tallest) {
res[i] = tallest + 1 - h[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;
const int maxn = 100000 + 10;
int a[maxn], maxh[maxn];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", a + i);
for (int i = n; i > 0; i--) maxh[i] = max(a[i], maxh[i + 1]);
for (int i = 1; i < n; i++) {
if (a[i] > maxh[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 n;
int main() {
cin >> n;
vector<int> ar(n), supp(n);
for (int i = 0; i < n; i++) cin >> ar[i];
int t = ar[n - 1];
for (int i = n - 2; i >= 0; i--) {
supp[i] = t;
t = max(t, ar[i]);
}
for (int i = 0; i < n - 1; i++) {
if (ar[i] > supp[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.lang.*;
public class codeforces {
static class FastIO {
InputStream dis;
byte[] buffer = new byte[1 << 17];
int pointer = 0;
public FastIO(String fileName) throws Exception {
dis = new FileInputStream(fileName);
}
... | 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 LuxuriousHouse1
{
public static void main(String args[])
{
int n,j,max=0,flag=0;
Scanner s=new Scanner(System.in);
n=s.nextInt();
//int[] a=new int[n+1];
int[] b=new int[n+1];
int[] c=new int[n+1];
for(int i=1;i<=n;i++)
{
b[i]=s.nextInt();
//b[i]=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 | a = int(input())
b = list(map(int, input().split()))
m = [0]*a
an =b[a-1]
for i in range(a-2, -1, -1):
m[i] = max(0, an - b[i] +1)
if b[i] > an:
an = b[i]
print(*m) | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
struct debugger {
static void call(string::iterator it, string::iterator ed) {}
template <typename T, typename... aT>
static void call(string::iterator it, string::iterator ed, T a, aT... rest) {
string b;
for (; *it != ','; ++it)
if (*it != ' ') 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(raw_input())
h = map(int, raw_input().split())
ans = []
arr = [0]*n
for i in xrange(n-2, -1, -1):
arr[i] = max(arr[i+1], h[i+1])
for i in xrange(n):
if h[i] > arr[i]:
ans.append(0)
else:
ans.append(arr[i]-h[i]+1)
#print arr
#print ans
print ' '.join(map(str, ans)) | PYTHON |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int a[100001], b[100001];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
int t = 0;
for (int i = n - 1; i >= 0; i--) {
b[i] = max(0, t - a[i] + 1);
t = max(a[i], t);
}
for (int i = 0; i < n; i++) cout << b[i] << " ";
return 0;... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | z = int(input())
l = list(map(int, input().rstrip().split(" ")))
a = [0]*z
m = l[-1]
if z ==1:
print(0)
else:
for i in range(z-2,0,-1):
if l[i] <= m:
a[i]=m-l[i]+1
if l[i]>m:
m = l[i]
if l[0] <= m:
a[0]=m-l[0]+1
for j in a:
print(j, end= " ")
| PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n=int(input())
l=list(map(int,input().split()))
m=0
d=[]
for i in range(n-1,-1,-1):
s=max(0,m+1-l[i])
d.append(s)
if(l[i]>m):
m=l[i]
print(*d[::-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.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Input... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class LuxuriousHouses {
public static void main(String[] args) throws IOException {
MyScanner sc = new MyScanner(System.in);
int n = sc.nextInt();
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;
long long powermod(long long _a, long long _b, long long _m) {
long long _r = 1;
while (_b) {
if (_b % 2 == 1) _r = (_r * _a) % _m;
_b /= 2;
_a = (_a * _a) % _m;
}
return _r;
}
long long string_to_number(string s) {
long long x = 0;
stringstream conv... | 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) {
try(Scanner scan = new Scanner(System.in)) {
int n = scan.nextInt();
int[] list = new int[n];
for (int i = 0; i < n; i++) list[i]=scan.nextInt();
int[] cumfreq = new int[n];
cumfreq[n-1]=list[n-1];
for (int i... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
# from fractions import *
from heapq import*
from bisect import *
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
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.util.*;
public class B581codeforces {
public static void main(String args[]){
Scanner s = new Scanner(System.in);
int n;
n = s.nextInt();
int[] a = new int[n];
for(int i=0;i<n;i++){
a[i] = s.nextInt();
}
int max=0;
for(int i = a.length-1;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.io.*;
import java.util.StringTokenizer;
public class B {
private static class Solution implements Runnable {
private static final long modulo = 1000000007;
private void solve() {
int n = in.nextInt();
int a[] = new int[n];
int segmentMax[] = new 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())
arr = list(map(int, input().split()))
arr.reverse()
count = 0
arr2 = []
for k in arr:
arr2.append(max(count+1-k, 0))
count = max(count, k)
arr2.reverse()
for kk in arr2:
print(kk, 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;
template <typename T>
T prod(const T &a, const T &b) {
return ((a % ((long long int)1e9 + 7)) * (b % ((long long int)1e9 + 7))) %
((long long int)1e9 + 7);
}
template <typename T>
T pow_(const T &a, const T &b) {
if (!b) return 1;
long long int p = pow_(a, 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 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, h, m[100000], k, mx = -1, m1[100000];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> m[i];
}
reverse(m, m + n);
for (int i = 0; i < n; i++) {
if (m[i] > mx) {
mx = m[i];
m1[i] = 0;
} else
m1[i] = mx - 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 | import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigDecimal;
public class R322B {
public static void main (String[] args) throws java.lang.Exception {
InputReader in = new InputReader(System.in);
PrintWriter w = new PrintWriter(System.out);
int n = in.nextInt();
... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n=int(raw_input())
h=map(int,raw_input().split())
h2=h[:]
for i in xrange(n-2,-1,-1):h[i]=max(h[i],h[i+1])
for i in xrange(n-1):print max(0,h[i+1]-h2[i]+1),
print 0
| PYTHON |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.util.*;
import java.io.*;
public class Main {
// File file = new File("input.txt");
// Scanner in = new Scanner(file);
// PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
public static void main(String[] args) {
// Scanner in = new Scanner(System.in);
... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n=int(raw_input())
a=map(int,raw_input().split())
b=[0]*n
b[-1]=a[-1]
for i in range(n-1):
b[n-i-2]=max(a[n-i-2],b[n-i-1])
for i in range(n-1):
if a[i]>b[i+1]:
print 0,
else:
print b[i+1]-a[i]+1,
print 0
| PYTHON |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = int(raw_input())
x = raw_input().split(" ")
maxsofar = 0
ans = []
for i in range(n-1, -1, -1):
x[i] = int(x[i])
if x[i] > maxsofar:
maxsofar = x[i]
ans.append("0")
else :
c = abs(x[i] - maxsofar) + 1
ans.append(str(c))
ans = ans[::-1]
print " ".join(ans) | PYTHON |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n], i, z = 0;
for (i = 0; i < n; i++) cin >> a[i];
for (i = n - 1; i >= 0; i--) {
if (a[i] <= z)
a[i] = z - a[i] + 1;
else {
z = a[i];
a[i] = 0;
}
}
for (i = 0; i < n; i++) cout << 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.util.StringTokenizer;
public class B {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.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 |
def get(data):
return data[1]
def get_answer(houses):
maxv = []
local_max = 0
for i in reversed(range(0 , len(houses))):
if houses[i] > local_max:
local_max = houses[i]
maxv.append(-1)
else:
maxv.append(local_max)
maxv = list(reversed(maxv))
... | 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.awt.Point;
import java.io.*;
import java.math.BigInteger;
public class CodeForces
{
FastScanner in;
PrintWriter out;
public void solve() throws IOException
{
int n = in.nextInt();
int mas[] = in.nextIntArray(n);
int res[] = ... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = int(input())
a = list(map(int,input().split()))
z,s=0,[]
for i in range(n-1,-1,-1):
if a[i]>z:s.append(0);z = a[i]
else:s.append(max(0,z+1-a[i]))
s.reverse()
print(*s) | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, ma;
int a[100010];
int b[100010];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
b[n] = 0;
ma = a[n];
if (n > 1)
for (int i = n - 1; i; i--) {
if (ma < a[i])
b[i] = 0;
else
b[i] = ma - a[i] + 1;
ma = m... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 |
n = int(input())
arr = list(map(int,input().split()))
k = arr[n - 1]
dp = [0] * n
for i in range(n - 2 , -1 , - 1):
if arr[i] > k :
dp[i] = 0
k = arr[i]
else:
dp[i] = k - arr[i] + 1
print(*dp)
| 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() {
long long n, q[100005], maxi = 0, ans[100005];
cin >> n;
for (long long i = 0; i < n; i++) cin >> q[i];
for (long long i = n - 1; i >= 0; i--) {
if (q[i] > maxi) {
ans[i] = 0;
maxi = q[i];
} else {
ans[i] = maxi - q[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;
const int MAXN = 100 * 1000;
int n;
int h[MAXN];
int main() {
cin >> n;
for (int a = 0; a < n; ++a) {
cin >> h[a];
}
int i = 0;
for (int a = n - 1; a >= 0; --a) {
int h1 = h[a];
h[a] = max(0, i - h1 + 1);
i = max(i, h1);
}
for (int a = 0; a < n... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = int(input())
a = list(map(int, input().split()))
maxH = 0
add = []
add.append(0)
for i in range(n - 1):
maxH = max(a[n - 1 - i], maxH)
add.append(max(0, maxH + 1 - a[n - 2 - i]))
for i in range(n):
print(add[n - 1 - 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;
map<int, int> m;
int a[1000001], ans[100000];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
int mx = a[n];
for (int i = n - 1; i > 0; i--) {
ans[i] = max(0, 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 | import java.util.Scanner;
/**
*
* @author Rishabh-PC
*/
public class Main {
public static void main (String args[])
{
Scanner stdIn = new Scanner(System.in);
int n,i,max=0,temp=0;
n = stdIn.nextInt();
int arr[] = new int[n];
for(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 = list(map(int, input().split()))
a = list(map(int, input().split()))
a.reverse()
mx = a[0]
ans = list()
ans.append(0)
for i in a[1:]:
ans.append(max(0, mx - i + 1))
mx = max(mx, i)
ans.reverse()
p = ''
for i in ans:
p += i.__str__() + ' '
print(p)
| 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 GCD(int x, int y) {
if (x % y == 0)
return y;
else
return (GCD(y, x % y));
}
int main() {
int n, x, i;
while (scanf("%d", &n) == 1) {
int ara[100005];
int ar[100005] = {0};
for (i = 0; i < n; i++) {
scanf("%d", &x);
ara[i] = x;
... | 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;
struct bui {
int fl;
int id;
} b[100100];
int ans[100100];
int main() {
int n;
while (~scanf("%d", &n)) {
for (int i = 1; i <= n; i++) {
scanf("%d", &b[i].fl);
;
b[i].id = i;
}
int index = 1;
int maxn = -1;
for (int i = n; i >= ... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int ans[100001];
int a[100001];
int main() {
int n, i, max1;
cin >> n;
max1 = 0;
for (i = 1; i <= n; i++) cin >> a[i];
for (i = n; i >= 1; i--) {
if (max1 > a[i]) {
ans[i - 1] = max1;
} else {
ans[i - 1] = a[i];
max1 = a[i];
}
}
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;
using ll = long long;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int &i : a) cin >> i;
vector<int> r(n);
int mx = 0;
for (int i = n - 1; i >= 0; --i)
r[i] = max(mx - a[i] + 1, 0), mx = max(mx, a[i]);
for (int i : r) cout << i << ' ';
return 0... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
int n;
cin >> n;
int ara[n];
for (int i = 0; i < n; i++) cin >> ara[i];
int max = ara[n - 1];
ara[n - 1] = 0;
for (int i = n - 2; i >= 0; i--) {
if (ara[i] <= max)
ara[i] = max - ara[i] + 1;
else {
ma... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e6;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
int h[n];
for (int i = 0; i < n; ++i) {
cin >> h[i];
}
vector<int> v(n, 0);
int maxx = 0;
for (int i = n - 1; i >= 0; i--) {
v[i] = max(0, maxx - h[... | 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 arr[100005], ans[100005];
int main(void) {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
ans[n - 1] = 0;
int large = arr[n - 1];
for (int i = n - 2; i > -1; i--) {
if (arr[i] > large) {
ans[i] = 0;
large = arr[i];
... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 |
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class B {
static StringTokenizer st;
static BufferedReader br;
static PrintW... | 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 MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
pair<long long, long long> arrR[100005];
long long arr[100005];
int main() {
long long n, fi = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
arrR[n - 1].first = arr[n - 1];
for (in... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
int main() {
int n, max = 0;
scanf("%d", &n);
int ara[n], ans[n], i, j;
for (i = 0; i < n; i++) {
scanf("%d", &ara[i]);
}
for (i = n - 1; i >= 0; i--) {
if (ara[i] > max) {
max = ara[i];
j = i;
}
if (max - ara[i] == 0 && i == j)
ans[i] = 0;
else... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.*;
public class Main {
static StreamTokenizer in=new StreamTokenizer(new BufferedReader(new InputStreamReader(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 | #include <bits/stdc++.h>
using namespace std;
const int MAXn = 1000 * 100;
int h[MAXn + 5], Max[MAXn + 5];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> h[i];
Max[n - 1] = h[n - 1];
for (int i = n - 2; i >= 0; i--) Max[i] = max(Max[i + 1], h[i]);
for (int i = 0; i < n - 1; i++) cout << ma... | 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(q) for q in input().split()]
c=0
d=l[::-1]
m=d[0]
ans=[0]
for i in range(1,len(l)):
ans.append(max(0,m-d[i]+1))
if d[i]>m:
m=d[i]
print(*ans[::-1]) | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | //package CF;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class A {
public static void main(String[] args) throws Exception
{
Scanner b... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = int(input())
h = list(map(int, input().split()))
stat = [0] * n
for i in range(n - 2, -1, -1):
stat[i] = max(stat[i + 1], h[i + 1])
for j in range(n):
if h[j] > stat[j]:
print('0', end = ' ')
else:
print(stat[j] - h[j] + 1, end = ' ') | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = int(raw_input())
a = map(int, raw_input().split())
lol = []
ma = a[-1]
lol.append(0)
for i in range(n-2,-1,-1):
if a[i]>ma:
ma = a[i]
lol.append(0)
else:
lol.append(ma-a[i]+1)
for i in range(n-1,-1,-1):
print lol[i], | PYTHON |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int i, n, a[100001], x[100001], max;
cin >> n;
for (i = 1; i <= n; i++) cin >> a[i];
x[n] = 0;
max = a[n];
for (i = n - 1; i > 0; i--) {
if (a[i] <= max)
x[i] = max - a[i] + 1;
else {
x[i] = 0;
max = a[i];
}
}
for (... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long a[100000] = {0};
long long r[100000] = {0};
int main() {
ios_base::sync_with_stdio(false);
long long n;
cin >> n;
for (long long i = 0; i < n; ++i) cin >> a[i];
long long m = a[n - 1];
for (long long i = n - 2; i >= 0; --i) {
if (a[i] <= m) r[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())
ls = list(map(int, input().split()))
ans = [0] * n
curr_max = ls[-1]
for i in range(n-2, -1, -1):
if ls[i] > curr_max:
curr_max = ls[i]
else:
ans[i] = (curr_max - ls[i] + 1)
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.Scanner;
/**
* Created by MenonS on 02-10-2015.
*/
public class B322 {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int h = scanner.nextInt();
int[] floors = new int[h];
int[] output = new int[h];
for(int i=0;i<h;i+... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.util.*;
public class CodeForces581{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int[] a = new int[n];
for(int i = 0;i<n;i++){
a[i] = input.nextInt();
}
int max = a[n-1];
a[n-1] = 0;
for(int i = n-2;i>=0;i--){
if(a[i] <= ma... | 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 r[100001];
int main() {
int n;
scanf("%d", &n);
int ar[n + 1];
for (int i = 0; i < n; i++) {
scanf("%d", &ar[i]);
}
int ma = ar[n - 1];
for (int i = n - 2; i > -1; i--) {
if (ma >= ar[i])
r[i] = ma - ar[i] + 1;
else
ma = ar[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() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int n, arr[100005] = {}, ans[100005] = {};
cin >> n;
long long int mx = -1e9;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
for (int i = n - 1; i >= 0; i--) {
if (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() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n = 0, max = 0;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
vector<int> ans(n);
for (int i = n - 1; i >= 0; i--) {
if (a[i] > max) {
ans[i] = 0;
max... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
bool is_digit(char c) {
if (c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' ||
c == '7' || c == '8' || c == '9') {
return true;
}
return false;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
ci... | 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[111111], n, B[111111];
int main() {
int i, ma = -1;
cin >> n;
for (i = 0; i < n; i++) cin >> A[i];
for (i = n - 1; i >= 0; i--) {
if (A[i] > ma) {
ma = A[i];
B[i] = 0;
} else {
B[i] = ma - A[i] + 1;
}
}
for (i = 0; i < n; i++)... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = int(input())
l = list(map(int,input().split()))
ans = [0]
tmp = l[-1]
for i in range(n-2,-1,-1):
ans.append(max(0 , tmp-l[i]+1))
if l[i] > tmp:
tmp = l[i]
#print(tmp)
print(*ans[::-1]) | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
long long fastpower(long long x, long long n, long long M) {
if (n == 0)
return 1;
else if (n % 2 == 0)
return fastpower((x * x) % M, n / 2, M);
else
return (x * fastpower((x * x) % M, (n - 1) / 2, M)) % M;
}
long long GCD(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 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n;
cin >> n;
long long int a1, i;
vector<long long int> a;
for (i = 0; i < n; i++) {
cin >> a1;
a.push_back(a1);
}
long long int maxa = 0;
long long int maxa1 = 0;
for (i = n - 1; i >= 0; i--) {
maxa1 = maxa;
maxa... | 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 i, n;
long long a[100005], high = 0, temp;
std::cin >> n;
for (i = 0; i < n; i++) {
std::cin >> a[i];
}
for (i = n - 1; i >= 0; i--) {
temp = a[i];
a[i] = max(0LL, high + 1 - a[i]);
high = max(temp, high);
}
for (i = 0; i < n... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
while (cin >> n) {
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
vector<int> mx(n);
for (int i = n - 2; i >= 0; i--) mx[i] = max(a[i + 1], mx[i + 1]);
for (int i = 0; i < n; i++) cout << max(0, mx[i] + 1 - a[i]) << " ... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, max = 0;
scanf("%d", &n);
int arr[n], result[n];
for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
result[n - 1] = 0;
max = arr[n - 1];
for (int i = n - 2; i >= 0; i--) {
if (arr[i] > max) {
max = arr[i];
result[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;
const int maxn = 100000 + 5;
int ar[maxn], br[maxn];
int n, ans, cns, MAX, MIN;
int main() {
while (cin >> n) {
memset(br, 0, sizeof(br));
for (int i = 0; i < n; i++) scanf("%d", &ar[i]);
MAX = 0;
for (int i = n - 1; i >= 0; i--) {
if (MAX < ar[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 First {
public static void main(String [] argv) {
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 localMax = a[n - 1];
ArrayList<Integer> ar = new ArrayList<Integer>();
ar.add(0);
for... | 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())
arr=[int(x) for x in input().split()]
ans=[0 for i in range(n)]
maxi=arr[-1]
for i in range(n-2,-1,-1):
if arr[i]>maxi:
maxi=arr[i]
ans[i]=0
else:
ans[i]=maxi-arr[i]+1
for i in ans:
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;
int n, a[100005], mx[100005];
int main() {
ios_base::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
mx[n] = a[n];
mx[n + 1] = 0;
for (int i = n - 1; i >= 1; i--) mx[i] = max(mx[i + 1], a[i]);
for (int i = 1; i <= n; i++)
if (a[... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int const N = 1e6 + 5;
int n, m, arr[N], b[N], cnt = 0, ma;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
ma = -100;
for (int i = n - 1; i >= 0; i--) {
if (ma < arr[i]) {
ma = arr[i];
} else {
b[i] = ma - 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 |
import com.sun.corba.se.impl.orbutil.ORBConstants;
import java.io.PrintWriter;
import java.util.*;
import java.util.Arrays ;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.Array;
public class Test{
static PrintWriter pw = new PrintWr... | 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.InputStreamReader;
import java.util.StringTokenizer;
public class B322 {
static int[]array;
public static void main(String [] args) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int n = 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 | import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
/**
* Created by sanjayarvind on 08/02/2017 AD.
*/
public class CR294B {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] buildings=new int[n];
... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int a;
cin >> a;
long* x = new long[a];
long* z = new long[a];
long max = 0;
for (long i = 0; i < a; i++) {
cin >> z[i];
}
bool in = 0;
for (long i = a - 1; i >= 0; i--) {
if (max < z[i]... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long v[100005];
long long st[400005];
void init(int idx, int a, int b) {
if (a == b) {
st[idx] = v[a];
} else {
int m = (a + b) / 2;
init(idx * 2 + 1, a, m);
init(idx * 2 + 2, m + 1, b);
st[idx] = max(st[idx * 2 + 1], st[idx * 2 + 2]);
}
}
lon... | 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, maxi = 0, temp;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = n - 1; i >= 0; i--) {
if (maxi >= a[i])
a[i] = maxi - a[i] + 1;
else {
maxi = a[i];
a[i] = 0;
}
}
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 | n = int(input())
arr = list(map(int, input().split()))
res = [0] * n
mx = -1
for i in range(n-1, -1, -1):
if arr[i] > mx:
mx = arr[i]
res[i] = 0
else:
add = max(0, mx + 1 - arr[i])
res[i] = add
print(*res) | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
int n;
while (~scanf("%d", &n)) {
vector<long long int> vec;
long long int a[n];
for (long long int i = 0; i < n; i++) cin >> a[i];
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 | #include <bits/stdc++.h>
using namespace std;
int h[100002], p[100002];
int main() {
int n, m = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> h[i];
}
for (int i = n - 1; i >= 0; i--) {
if (h[i] > m) {
p[i] = 0;
m = h[i];
} else {
p[i] = (m + 1) - h[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 | #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];
int maxh = 0;
for (int i = n - 1; i >= 0; i--) {
sol[i] = max(0, maxh + 1 - a[i]);
if (a[i] > maxh) maxh = a[i];
}
for (int i = 0; i < n; i++) cout << sol[... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n=int(input())
l=list(map(int,input().split()))
mx=0
ans=[]
for i in range (n-1,-1, -1):
if l[i] >mx:
mx=l[i]
ans.append(0)
elif l[i]==mx:
ans.append(1)
else:
ans.append(mx-l[i]+1)
ans.reverse()
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 a[100005], ans[100005];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
int tmp = 0;
for (int i = n; i >= 1; --i) {
ans[i] = max(tmp + 1 - a[i], 0);
tmp = max(tmp, a[i]);
}
for (int i = 1; i <= n; ++i) printf("... | 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()))
etaj = [0] * n
ma = A[-1]
for i in range(-2, -n-1, -1):
if A[i] > ma:
ma = A[i]
elif A[i] == ma:
etaj[i] = 1
else:
etaj[i] = ma - A[i] + 1
for elem in etaj: print(elem, end = ' ')
| PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = int(input())
home = list(map(int, input().split()))
suff = [0] * n
for i in range(n - 2, -1, -1):
suff[i] = max(suff[i + 1], home[i + 1])
for i in range(n):
if home[i] > suff[i]:
print(0, end=" ")
else:
print(suff[i] - home[i] + 1, end=" ")
| PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = int(input())
a = [int(i) for i in input().split()]
ans = []
m = 0
for i in range(n - 1, -1, -1):
if a[i] <= m:
ans.append(m - a[i] + 1)
elif a[i] > m:
ans.append(0)
m = a[i]
print(*ans[::-1]) | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.