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.io.*;
import java.util.Stack;
import java.util.StringTokenizer;
public class Main {
static BufferedReader bufferedReader;
static PrintWriter printWriter;
static StringTokenizer stringTokenizer;
static void solve() throws Exception {
int houses = nextInt();
int 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 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, a[100009], b[100009], i, flag = 0;
cin >> n;
for (i = 0; i < n; i++) cin >> a[i];
for (i = n - 1; i >= 0; i--) {
if (a[i] > flag)
b[i] = -1;
else
b[i] = max(a[i], flag);
flag = max(flag, a[i]);
}
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 | #include <bits/stdc++.h>
using namespace std;
int main() {
size_t n;
cin >> n;
vector<int> houses(n);
for (size_t i = 0; i < n; ++i) {
cin >> houses[i];
}
vector<int> res(n);
int max_elem = 0;
for (size_t i = 0; i < n; ++i) {
size_t j = n - 1 - i;
if (houses[j] > max_elem) {
max_elem =... | 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()); li = list(map(int, input().split(" ")))
lu = []
k = 0
for i in range(n-1, -1, -1):
lu.append(max(0, k+1-li[i]))
k = max(k, li[i])
lu.reverse()
print(' '.join(map(str, lu)))
| 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 solve() {
int n, m = 0;
cin >> n;
vector<pair<int, int>> a(n);
for (auto &u : a) cin >> u.first;
a[n - 1].second = 0;
for (int i = n - 2; i >= 0; i--) {
m = max(m, a[i + 1].first);
a[i].second = max(m, a[i + 1].first);
}
for (auto &u : 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 | import java.util.Scanner;
public class codeforces581B
{
public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
StringBuilder sb = new StringBuilder();
int n=s.nextInt(),i;
int[] a = new int[n];
int[] m = new int[n];
for(i=0;i<n;i++)
a[i]=s.nextInt();
m[n-1]=a[n-1];
for(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 | #~ import io
#~ import sys
#~ import time
#~ start = time.clock()
#~ test = '''5
#~ 1 2 3 1 2'''
#~ test = '''4
#~ 3 2 1 4'''
#~ sys.stdin = io.StringIO(test)
n = int(input())
floors = list(map(int, input().split()))
#~ print(floors)
ma = floors[:]
max_so_far = float("-inf")
for i in range(n-1,-1,-1):
ma[i] = max(... | 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;
const double PI = acos(-1.0);
const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 2000 * 1000 * 1000;
const int MAXN = 100010;
template <typename T>
inline T sqr(T n) {
return n * n;
}
int n;
int a[MAXN], ans[MAXN], suff;
int main() {
scanf(... | 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[100100], n, b[100100], mx = -1e10;
set<pair<int, int> > ss;
int main() {
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
b[n - 1] = a[n - 1];
for (int i = n - 2; i >= 0; i--) {
b[i] = max(b[i + 1], a[i]);
}
for (int i = 0; i < n - 1; i++) {
... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = int(raw_input())
l = map(int, raw_input().split())
m = [0]*n
max_value = 0
for i in xrange(n-1, -1,-1):
max_value = max(max_value, l[i])
m[i] = max_value
for i in xrange(n-1):
ans = m[i+1] - l[i]
if ans < 0: ans = 0
else: ans += 1
print ans,
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())
l=map(int,raw_input().split())
ans=[0]
cnt,chk=l[-1],1
for i in l[-2::-1]:
if i<=cnt:
ans.append(cnt-i+1)
else:
cnt=i
ans.append(0)
print ' '.join(map(str,ans[::-1])) | PYTHON |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.util.*;
public class test {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[n];
int[] anss = new int[n];
int[] dh = new int[n];
for (int i = 0; i < n; i++)
arr[i] = sc.nextInt();
dh[n-1] = 0;
anss[n-1]=0;
String... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int arr[n];
int max_r;
int b[n];
fill(b, b + n, 0);
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
max_r = arr[n - 1];
for (int i = n - 2; i >= 0; i--) {
if (max_r < arr[i]) {
max_r = arr[i];
} else
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 | n = int(raw_input())
inp = raw_input()
inp =inp.split()
houses = [int(i) for i in inp]
added=[0 for i in inp]
max=0
for i in range(n-1,-1,-1):
if houses[i]<=max:
added[i]= max - houses[i]+1
if houses[i]>max:
max=houses[i]
for i in added:
print i, | PYTHON |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N], b[N];
int main() {
int n;
while (scanf("%d", &n) != EOF) {
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
int mmax = a[n];
b[n] = 0;
for (int i = n - 1; i > 0; i--) {
if (a[i] == mmax)
b[i] =... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = int(input())
h = list(map(int, input().split()))
cur = 0
l = [0] * n
for i in range(n - 1, -1, -1):
l[i] = max(0, cur + 1 - h[i])
cur = max(cur, h[i])
print (" ".join(map(str, l)))
| PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int b, d, n, m, i, j, v[2100000], f[100001], maxi, a, ul, nrq = 1, nrr = 1,
newq, newr, ls, ld;
char s[100005], z;
vector<int> c;
double r, t, q, ff, pri;
bool cmm(int a, int b) {
if (a > b) return 1;
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 | #!/usr/bin/python
if __name__ == '__main__':
size = int(raw_input().strip())
arr = [int(x) for x in raw_input().strip().split(" ")]
max_num = -1
op = []
for i in reversed(arr):
if i == max_num:
op.append(1)
elif i > max_num:
op.append(0)
max_num ... | 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 long long Nmax = 1000000000;
int n;
vector<long long> a;
vector<long long> tree;
void add(int x, int i, int l, int r, int pos) {
if (i < l || i > r) return;
if (l == r) {
tree[pos] = x;
return;
}
int mid = (l + r) / 2;
add(x, i, l, mid, pos * 2);
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;
const int MXN = 1e5 + 3;
long long n, sum, mx = -MXN, id;
int main() {
long long a[MXN];
pair<int, int> b[MXN];
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = n; i >= 1; i--) {
if (a[i] > mx) {
mx = a[i];
id = 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;
string Y = "YES";
string N = "NO";
string yy = "Yes";
string nn = "No";
int main() {
long long n;
while (cin >> n) {
long long ar[n];
for (long long i = 0; i < n; i++) {
cin >> ar[i];
}
long long mx = 0;
vector<long long> v(n);
for (long lo... | 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 | T = int(input())
st = raw_input().split()
st = list(map(int,st))
mx = 0
a = [0]*T
for i in range(T-1,-1,-1):
a[i] = max(0,mx + 1 - st[i])
mx = max(mx,st[i])
for i in range(0,T):
print a[i],
| PYTHON |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
int n;
cin >> n;
int a[n + 1], ans[n + 1];
for (int i = 0; i < n; i++) cin >> a[i];
int max = a[n - 1];
for (int i = n - 2; i >= 0; i--) {
if (a[i] > max)
ans[i] = 0, 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 = int(input())
a = list(map(int, input().split()))
_max = max(a)
b = [0] * n
b[n - 1] = 0
c = a[n - 1]
for i in range(n - 2, -1, -1):
if(a[i] > c):
b[i] = 0
c = a[i]
else:
c = max(c, a[i])
b[i] = c - a[i] + 1
for i in range(n):
print(b[i]) | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | from sys import *
inp = lambda : stdin.readline()
def main():
n = int(inp())
l = [int(i) for i in inp().split()]
maxl,maxe = [0 for i in range(n)],0
for i in range(n-1,-1,-1):
maxe = max(maxe, l[i])
maxl[i] = maxe
for i in range(n-1):
print(max(0,maxl[i+1]-l[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 | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class Codeforces {
StringTokenizer tok;
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 | import java.util.Scanner;
public class B {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] hs = new int[n];
for (int i = 0; i < n; i++)
hs[i] = sc.nextInt();
sc.close();
long[] max = new long[n + 1];
for (int i = n - 1; i >= 0; i--)
max[i]... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | /**
*
* @author Faruk
*/
import java.util.Arrays;
import java.util.Scanner;
import java.util.HashSet;
import java.util.HashMap;
import java.util.ArrayList;
public class tmp {
public static void main(String [] args){
Scanner scan = new Scanner(System.in);
int n = scan.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 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long i, mi, n, a[100005], b[100005];
cin >> n;
for (i = 0; i < n; i++) cin >> a[i];
mi = a[n - 1];
b[n - 1] = 0;
for (i = n - 2; i >= 0; i -= 1) {
if (a[i] > mi) {
b[i] = 0;
mi = a[i];
} else if (a[i] == mi) {
b[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 main() {
int n;
cin >> n;
int arr[n];
int ans[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int max = 0;
for (int i = n - 1; i >= 0; i--) {
int flag = 0;
if (arr[i] > max) {
max = arr[i];
flag = 1;
}
if (max == 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.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
/**
*
* @author Shreyas
*/
public class Height {
/**
* @param args the command line arguments
*/
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 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static... | 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 = [ int(x) for x in input().split() ] + [ 0 ]
s = [ 0 for x in range(n) ]
m = a[-1]
for i in range(n):
m = max(m , a[n - i])
s[n - i - 1] = m
res = ''
for i in range(n):
res += str(max(s[i] - a[i] + 1, 0)) + ' '
print(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 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
public class P322_2B implements Runnable {
int nextInt(StreamTokenizer in) throws Exception {
in.nextToken();
return (int) in.nval;
}
StreamTokenizer in;
private int 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 | #!/usr/bin/env python
n = input()
a = map(int,raw_input().split())
b = [None] * n
b[n-1] = 0
i = n-2
tmp = 0
while i >= 0:
tmp = max(tmp, a[i+1])
b[i] = max(0, tmp+1-a[i])
i-=1
for x in range(0,n) : print b[x], | 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 N = 1e5 + 1;
int a[N], n, b[N], maxn;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
b[n] = 0;
maxn = a[n];
for (int i = n - 1; i >= 1; i--) {
if (a[i] > maxn) {
b[i] = 0;
maxn = a[i];
} else {
b[i] = maxn - 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 | import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from itertools import combinations, permutations
# input = sys.stdin.readline
flush = lambda: sys.stdout.flush
comb = lambda x, y: (factorial(x) // factorial(y)) // factorial(x - y)
# inputs
# ip ... | 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 string YESNO[2] = {"NO", "YES"};
const string YesNo[2] = {"No", "Yes"};
const string yesno[2] = {"no", "yes"};
void YES(bool t = 1) { cout << YESNO[t] << '\n'; }
void Yes(bool t = 1) { cout << YesNo[t] << '\n'; }
void yes(bool t = 1) { cout << yesno[t] << '\n'; }
temp... | 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, i, j;
int max = INT_MIN;
scanf("%d", &n);
int a[n];
int b[n];
for (i = 0; i < n; ++i) {
scanf("%d", &a[i]);
}
for (j = n - 1; j >= 0; --j) {
if (a[j] <= max) {
b[j] = max + 1 - a[j];
} else {
b[j] = 0;
}
if (max < a[j]) {
... | 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 + 1], maxx[n + 1];
for (int i = 1; i < n + 1; ++i) cin >> a[i];
maxx[n] = a[n];
for (int i = n - 1; i > 0; --i) maxx[i] = max(maxx[i + 1], a[i]);
for (int i = 1; i < n; ++i)
if (maxx[i + 1] >= a[i])
cout << maxx[... | 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 = 100005;
int n;
int h[maxn], r[maxn];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d", &h[i]);
}
memset(r, 0, sizeof(r));
for (int i = n; i >= 1; --i) {
if (i == n) continue;
r[i] = max(h[i + 1], r[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;
void Rd(int &res) {
char c;
res = 0;
while (c = getchar(), !isdigit(c))
;
do {
res = (res << 3) + (res << 1) + (c ^ 48);
} while (c = getchar(), isdigit(c));
}
int A[100005], B[100005];
int main() {
int n, i, j, k;
scanf("%d", &n);
for (i = 1; i <= n... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int mx, n, n1, k, a[100000], b[100000];
int main() {
cin >> n;
mx = 0;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = n - 1; i >= 0; i--) {
b[i] = max(0, (mx - a[i] + 1));
mx = max(mx, a[i]);
}
for (int i = 0; i < n; i++) cout << b[i] << " ";
re... | 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 B {
public static void main(String args[]) {
try {
InputReader in = new InputReader(System.in);
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
int n = in.readInt();
... | 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 sun.font.FontRunIterator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
/**
* Created by baba_beda on 9/22/15.
*/
public class B {
public static void main(String[] args) {
new B().run();
}
Scanner in;
void run() {
try {
in = new ... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int a[100009], i, j, k, l, m, n, b[100009];
while (cin >> n) {
for (i = 0; i < n; i++) {
cin >> a[i];
}
m = a[n - 1];
b[n - 1] = 0;
k = 0;
for (i = n - 2; i >= 0; i--) {
if (m - a[i] == 0) {
b[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())
v = list(map(int, input().split()))
v1 = [0]*n
m = 0
for i in range(n):
if v[-i-1]>m:
m=v[-i-1]
else:
v1[-i-1]=m-v[-i-1]+1
print(' '.join(map(str,v1))) | 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;
/**
* Created by Microsoft on 18/10/2015.
*/
public class algo_contest1_q5 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(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 | import java.util.Arrays;
import java.util.Scanner;
public class BigRecursion {
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[] b = new int[n];
b[n-1] = 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 | n=int(input())
lst=list(map(int,input().split()))
res,mx=[0],lst[-1]
for i in range(n-2,-1,-1):
x=lst[i]
if x<=mx:res.append(mx-x+1)
else:res.append(0);mx=x
res.reverse()
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 | n = int(input())
h = list(map(int, input().split())) + [0]
h_max = 0
res = [0] * n
for i in range(n, 0, -1):
h_max = max(h_max, h[i] + 1)
res[i - 1] = max(h_max - h[i - 1], 0)
print(" ".join(map(str, 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;
int main() {
int p, n;
cin >> n;
int a[100001] = {}, dp[100001], h[100001] = {};
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
dp[n - 1] = a[n - 1];
for (int i = n - 2; i >= 0; --i) {
if (a[i] == dp[i + 1]) h[i] = 1;
dp[i] = max(dp[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 | n=int(input())
l=list(map(int,input().split()))
s=[0]*n
a=[0]*n
s[-1]=l[-1]
for i in range(1,n):
if l[n-i-1]<=s[n-i]: a[n-i-1]=s[n-i]-l[n-i-1]+1
s[n-i-1]=max(l[n-i-1],s[n-i])
print(' '.join(map(str,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;
long double PI = acosl(-1);
bool compare_int(int a, int b) { return (a > b); }
bool compare_string(string a, string b) { return a.size() < b.size(); }
bool compare_pair(const pair<int, int> &a, const pair<int, int> &b) {
return (a.second < b.second);
}
long long int fact(... | 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 B322 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int arr[] = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = in.nextInt();
}
int max=0;
int ans[]= new int [n];
for(int i=arr.length-1;i>=0;i--){
i... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = int(input())
h = [int(x) for x in input().split()]
tmp = []
for i in range (n):
tmp.append(0)
tmp[n - 1] = h[n - 1]
for i in range (n - 2, -1, -1):
if h[i] > tmp[i + 1]:
tmp[i] = h[i]
else:
tmp[i] = tmp[i + 1]
for i in range (n - 1):
if h[i] == tmp[i + 1]:
print(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 |
import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
public static void main(String[] args) throws java.lang.Exception {
Reader pm =new Reader();
int n = pm.nextInt();
int[] a = new int[n];
for(int i=0;i<n;i++){
a[i] = pm.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())
houses = [int(x) for x in raw_input().split()]
m = 0
ans = [0] * n
for i in xrange(n-1, -1, -1):
if houses[i] <= m:
ans[i] = m - houses[i] + 1
else:
ans[i] = 0
m = max(houses[i], m)
print " ".join([str(x) for x in ans])
| PYTHON |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n=int(input())
a=list(map(int,input().split()))
a.reverse()
c=[]
c.append(0)
maxi=a[0]
for i in range(len(a)-1):
if(a[i+1]>maxi):
c.append(0)
maxi=a[i+1]
elif(a[i+1]<=maxi):
c.append(abs(1+maxi-a[i+1]))
c.reverse()
print(*c)
| 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 | 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.pop();
} else {
if (last_floor === prev_floor) {
result.unshift(... | 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()))
b = [0] * n
ma = a[-1]
for i in range(n - 2, -1, -1):
if a[i] <= ma:
b[i] = ma - a[i] + 1
else:
ma = a[i]
string_ints = [str(int) for int in b]
print(" ".join(string_ints)) | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long arr[100005], arr2[100005];
map<long long, int> cnt;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
cnt[arr[i]]++;
arr2[i] = arr[i];
}
for (int i = n - 2; i >= 0; i--) {
arr2[i] = max(arr2[i], arr2[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 = [int(x) for x in input().split()]
m = [0] * (n + 1)
m[n] = - 10 ** 9 - 7
for i in range(n-1,0,-1):
m[i] = max(m[i+1], a[i])
for i in range(n):
print(max(a[i], m[i+1] + 1) - a[i], end=' ')
| PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = int(input())
a = list(map(int, input().split()))
ans = []
m = 0
for i in range(n - 1, -1, -1):
ans.append(max(0, (m + 1) - a[i]))
m = max(m, a[i])
ans.reverse()
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 | n = input("")
hString = raw_input("")
h = hString.split(" ")
h = map(int, h)
result = ["0"]
prevMax = n - 1
for i in range(n-2, -1, -1):
if h[prevMax] < h[i]:
result.append("0")
prevMax = i
else:
result.append(str(h[prevMax] - h[i] + 1))
print " ".join(result[::-1]) | PYTHON |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int tmp = 0, index;
for (int i = n - 1; i >= 0; i--) {
if (tmp < arr[i]) {
tmp = arr[i];
index = i;
}
if (i == index) {
arr[i] = 0;
}... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.util.*;
public class _581B_Luxurious_Houses {
public static void main(String[] args){
Scanner leer = new Scanner(System.in);
int n = leer.nextInt();
long h[]= new long[n];
for (int i = 0; i < n; i++){
h[i]= leer.nextLong();
}
long T[]= new long[n+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 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.precision(20);
int n;
cin >> n;
int a[n];
vector<int> v;
for (int i = 0; i < n; i++) cin >> a[i];
v.push_back(0);
int m = a[n - 1];
for (int i = n - 2; i >= 0; i--) {
if (a[i] > 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 | #!/usr/bin/env python3
# 20150929
# 11:10PM-
def main():
n = int(input())
a = list(map(int, input().split()))
b = [0]*len(a)
m = a[-1]
for i in range(len(a)-2,-1,-1):
if a[i] > m:
m = a[i]
else:
b[i] = m - a[i] + 1
print(' '.join(map(str,b)))
if _... | 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 array
def main():
n = int(input())
hs = input().split()
maxi = 0
p = array.array('Q', n * [0])
for i in range(n - 1, -1, -1):
hi = int(hs[i])
p[i] = max(0, maxi - hi + 1)
maxi = max(maxi, hi)
for i in range(n - 1):
print(p[i], '', end='')
print(p[n... | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.util.*;
import java.io.*;
public class Luxurious_Houses
{
public static void main(String args[]) throws Exception
{
BufferedReader f=new BufferedReader(new InputStreamReader(System.in));
int runs=Integer.parseInt(f.readLine());
StringTokenizer st=new StringTokenizer(f.readLine());
int[] arr=new 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 | # -*- coding: utf-8 -*-
import sys,math,heapq,itertools as it,fractions,re,bisect,collections as coll
n = int(raw_input())
h = map(int, raw_input().split())
mx = [0] * n
for i in xrange(n - 2, -1, -1):
mx[i] = max(mx[i + 1], h[i + 1])
ans = [max(0, mx[i] - h[i] + 1) for i in xrange(n)]
print " ".join(map(str, an... | 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.*;
public class testP02 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] h=new int[n];
for(int i=0;i<n;i++)
h[i]=sc.nextInt();
int[] a=new int[n];
... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, h[100008], mayor, resp[100008], mayores[100008];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d", &h[i]);
}
mayor = -1;
for (int j = n - 1; j >= 0; j--) {
mayores[j] = mayor;
if (h[j] > mayor) {
mayor = h[j];
}
... | 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.Locale;
import java.util.StringTokenizer;
public class Main implements Runnable {
final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
public static void main... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n=input()
a=map(int,raw_input().split())
rs=[0]*n
mx=0
for i in xrange(n-1,-1,-1):
rs[i]=max(mx+1,a[i])
mx=max(mx,a[i])
for i in xrange(n):
print rs[i]-a[i], | PYTHON |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long n, arr[100005], Max, ans[100005];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for (long long i = (long long)(1); i <= (long long)(n); i++) cin >> arr[i];
Max = arr[n];
ans[n] = 0;
for (long long i = (long long)(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;
long long h[100010], a[100010];
int main() {
int n;
while (cin >> n) {
memset(a, 0, sizeof(a));
for (int i = 0; i < n; ++i) cin >> h[i];
a[n - 1] = 0;
if (n > 1) a[n - 2] = h[n - 1];
for (int i = n - 3; i >= 0; --i) {
a[i] = max(a[i + 1], 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;
bool compare(int a, int b) { return a > b; }
class Compare {
public:
bool operator()(int a, int b) { return a > b; }
};
int mod(int a, int b) { return ((a % b) + b) % b; }
int a[100009], n, suffix[100009];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) sca... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, a[N];
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
int mx = a[n - 1];
vector<int> v;
v.push_back(0);
for (int i = n - 2; i >= 0; i--) {
if (a[i] >... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.io.*;
import java.util.*;
public class test {
int INF = (int)1e9;
long MOD = 1000000007;
void solve(InputReader in, PrintWriter out) throws IOException {
int n = in.nextInt();
int[] a = new int[n];
for(int i=0; i<n; i++) {
a[i] = 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 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
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 | #include <bits/stdc++.h>
using namespace std;
long long int pwr(long long int a, long long int b, long long int mod) {
a %= mod;
if (a < 0) a += mod;
long long int ans = 1;
while (b) {
if (b & 1) ans = (ans * a) % mod;
a = (a * a) % mod;
b /= 2;
}
return ans;
}
long long int gcd(long long int 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 | import java.util.*;
public class HelloWorld{
public static void main(String []args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] arr=new int[n];
for(int i=0;i<n;i++){
arr[i]=sc.nextInt();
}
int[] ans=new int[n];
ans[n-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 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long i, n, a, max = -1;
cin >> n;
vector<int> v, m;
while (n--) {
cin >> a;
v.push_back(a);
}
for (i = v.size() - 1; i >= 0; i--) {
if (v[i] > max) max = v[i];
m.push_back(max);
}
for (i = 0; i < v.size() - 1; i++) {
if ... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | # your code goes here
n = int(raw_input())
h = map(int, raw_input().split())
l=[0]*n
max = 0
arr = h[::-1]
# print h, arr
for i in range(n):
if arr[i] <= max:
l[i] = max - arr[i] + 1
else:
max = arr[i]
# print max
l = l[::-1]
print ' '.join(str(x) for x in 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 | n = int(input())
h = [i for i in map(int, input().split())]
h = h[::-1]
ans = []
maxH = h[0]
for i in range(1, len(h)):
if maxH - h[i] + 1 < 0:
ans.append(0)
else:
ans.append(maxH - h[i] + 1)
maxH = max(maxH, h[i])
ans = ans[::-1]
ans.append(0)
print(*ans) | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.util.Scanner;
public class probACon322 {
/**
* @param args
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = 0;
n = sc.nextInt();
int[] houses = new int[n];
int[] diff = new int[n];
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 | n = input()
s = map(int,raw_input().split())
a = s[-1]
b = ['0']
for i in xrange(n-2,-1,-1):
if s[i]==a:
b.append('1')
elif s[i]>a:
b.append('0')
else:
b.append(str(a+1-s[i]))
a = max(a,s[i])
print ' '.join(b[::-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 | from math import *
from Queue import *
from sys import *
from datetime import *
n = int(raw_input())
h = map(int, raw_input().split())
m = [0 for i in range(n)]
m[n-1] = h[n-1]
for i in range(n-2, -1, -1):
m[i] = max(m[i+1], h[i])
res = []
for i in range(n-1):
res.append(max(m[i+1]-h[i]+1,0))
res.append(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.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String args[]) throws IOException {
BufferedReader in;
File f = new File("entrada.txt");
Str... | 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;
scanf("%d", &n);
int a[n], r[n];
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
int mx = a[n - 1];
r[n - 1] = 0;
for (int i = n - 2; i > -1; i--) {
if (mx >= a[i])
r[i] = mx - a[i] + 1;
else
mx = a[i], r[i] = 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;
int main() {
int n;
cin >> n;
vector<int> v(n), res(n);
for (int i = 0; i < n; i++) cin >> v[i];
reverse(v.begin(), v.end());
int mx = v[0];
res[0] = 0;
for (int i = 1; i < n; i++) {
if (v[i] > mx) {
mx = v[i];
res[i] = 0;
} else {
... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, i, max;
cin >> n;
long long int a[n], b[n + 1];
for (i = 0; i < n; i++) cin >> a[i];
max = a[n - 1];
for (i = n - 1; i >= 0; i--) {
if (a[i] >= max) {
b[i] = a[i];
max = a[i];
} else
b[i] = b[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()))
x=a[n-1]
b=[0]*n
for i in range(n-2,-1,-1):
b[i]=max(0,x-a[i]+1)
if a[i]>x:x=a[i]
print(*b) | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.io.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 |
603_A. Alternative Thinking | Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | 2 | 7 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
... | JAVA |
603_A. Alternative Thinking | Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | 2 | 7 | import java.io.*;
import java.util.*;
public class A603 {
public static void main(String[] args) throws IOException {
input.init(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = input.nextInt();
int res = 1;
char[] s = input.next().toCharArray();
for(int i= 1; i<n; i++) if(s[i... | JAVA |
603_A. Alternative Thinking | Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | 2 | 7 | input()
a = input()
s = []
for c in a:
if not s or s[-1][0] != c:
s.append([c, 1])
else:
s[-1][1] += 1
s2 = sorted(s, key=lambda x: x[1])
delta = 0
if s2[-1][1] >= 3 or len(s2) > 1 and s2[-2][1] >= 2:
delta = 2
elif s2[-1][1] >= 2:
delta = 1
print(len(s) + delta) | PYTHON3 |
603_A. Alternative Thinking | Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | 2 | 7 | import java.io.*;
import java.math.*;
import java.util.*;
/**
*
* @author Saju
*
*/
public class Main {
private static int dx[] = { 1, 0, -1, 0 };
private static int dy[] = { 0, -1, 0, 1 };
private static final long INF = Long.MAX_VALUE;
private static final int INT_INF = Integer.MAX_VALUE;
... | JAVA |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.