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 |
|---|---|---|---|---|---|
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n, q, a, b;
char c;
map<int, int> mpU, mpL;
int main() {
scanf("%d%d", &n, &q);
mpU[0] = 0, mpL[0] = 0;
while (q--) {
scanf("%d%d", &a, &b);
getchar();
scanf("%c", &c);
if (c == 'U') {
auto itL = mpL.lower_bound(b);
auto itU = mpU.lower... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
template <class T>
inline T mod_v(T num) {
if (num >= 0)
return num % 1000000007;
else
return (num % 1000000007 + 1000000007) % 1000000007;
}
template <class T>
inline T gcd(T a, T b) {
a = abs(a);
b = abs(b);
while (b) b ^= a ^= b ^= a %= b;
return a;
}... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n, m;
map<int, int> mp1, mp2;
map<int, bool> used;
inline int read() {
int red = 0, f_f = 1;
char ch = getchar();
while (ch > '9' || ch < '0') {
if (ch == '-') f_f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') red = red * 10 + ch - '0', ch = g... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 |
import java.io.*;
import java.util.*;
/**
* Created by sbabkin on 9/14/2015.
*/
public class SolverE {
public static void main(String[] args) throws IOException {
new SolverE().Run();
}
BufferedReader br;
PrintWriter pw;
StringTokenizer stok;
private String nextToken() throws IOEx... | JAVA |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, q, x, y, ans;
char cc;
cin >> n >> q;
map<int, pair<char, int>> mp;
mp[0] = make_pair('U', n + 1);
mp[n + 1] = make_pair('L', n + 1);
while (q--) {
cin >> x >> y >> cc;
au... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;
/**
* Created by hama_du on 15/07/09.
*/
public class C {
public static void main(String[] args) {
InputRea... | JAVA |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
int const MAX = 400400;
int const SZ = 4 * MAX;
int tree[2][SZ];
void modify(int id, int v, int l, int r, int from, int to, int val) {
if (r <= from || to <= l) return;
if (from <= l && r <= to) {
tree[id][v] = std::max(tree[id][v], val);
return;
}
int m = (l + r) / 2;
modify(... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
map<int, int> l, u;
int n, q, ans, x, y;
char opt;
void up() {
ans = 0;
map<int, int>::iterator it = u.lower_bound(x);
if (it == u.end())
ans = y;
else
ans = y - (it->second);
printf("%d\n", ans);
l[y] = x;
u[x] = y - ans;
}
inline void left() {
ans ... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class C {
BufferedReader reader;
StringTokenizer tokenizer;
PrintWriter out;
public void solve() throws IOException {
int N = nextInt();
int Q = n... | JAVA |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int x[200010], y[200010];
int n, q;
int main() {
ios::sync_with_stdio(false);
cin >> n >> q;
mp[0] = mp[n + 1] = q;
while (q--) {
char c;
cin >> x[q] >> y[q] >> c;
map<int, int>::iterator it = mp.lower_bound(x[q]);
if (it->first == ... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n, m;
int a, b;
char c;
set<pair<int, int> > st;
set<pair<int, int> >::iterator it;
int x[200005], y[200005];
int main() {
cin >> n >> m;
int i;
st.insert(make_pair(0, 0));
st.insert(make_pair(n + 1, m + 1));
for (i = 1; i <= m; i++) {
cin >> y[i] >> x[i];... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
char c[3];
map<int, int> vis;
map<int, int> vis1;
set<int> st1;
set<int> st2;
int main() {
int n, m, i, j, k, x, y, z, u, v;
scanf("%d%d", &n, &m);
set<int>::iterator it1, it2;
st1.insert(n + 1);
st2.insert(n + 1);
st1.insert(0);
st2.insert(0);
while (m--) {... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int Len = 2333333;
char buf[Len], *p1 = buf, *p2 = buf, duf[Len], *q1 = duf;
inline char gc();
inline int rd();
inline void pc(char c);
inline void rt(int x);
inline void flush();
template <class T>
inline T Max(T a, T b) {
return a > b ? a : b;
}
template <class T>... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | 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;
import java.util.TreeMap;
import java.util.TreeSet;
public class E {
public static void main(String[] ar... | JAVA |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
set<pair<pair<int, int>, int> > S;
int n, q;
int main() {
cin >> n >> q;
for (int i = 0; i < q; i++) {
pair<pair<int, int>, int> nu;
char dir[2];
cin >> nu.first.first >> nu.first.second >> dir;
if (dir[0] == 'U')
nu.first.second = 0;
else
... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int const N = 2e5 + 781;
int const INF = 2e9;
int q, cn, TL[N * 4], TU[N * 4], vL[N], vU[N], h[N];
set<pair<int, int>> had;
struct z {
int x, y, t, id, hv;
z(){};
z(int x, int y, int t, int id) : x(x), y(y), t(t), id(id){};
};
vector<z> qs;
vector<pair<int, int>> a;
v... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int N = 400010;
int q;
long long k;
int n = 0;
map<pair<int, int>, int> was;
set<pair<int, int> > u;
set<pair<int, int> > l;
set<pair<int, int> >::iterator it;
char typ[N];
pair<int, int> qer[N];
int en = 0;
map<int, int> id;
int name[N];
int cod[N];
int tre[2][4 * N]... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int const M = 202020;
long long const mod = 1000000007LL;
map<int, int> mpu, mpl, mpu2, mpl2;
int idu, idl, idu2, idl2;
int getUId(int x) {
if (mpu.find(x) == mpu.end()) mpu[x] = idu++;
return mpu[x];
}
int getUId2(int x) {
if (mpu2.find(x) == mpu2.end()) mpu2[x] = id... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
int n, q;
int mn[N << 2];
vector<int> vx, vy;
int x[N], y[N], d[N];
int idx(int val) { return lower_bound(vx.begin(), vx.end(), val) - vx.begin(); }
int idy(int val) { return lower_bound(vy.begin(), vy.end(), val) - vy.begin(); }
int mx[2][N << 2]... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | import java.util.*;
import java.io.*;
/*
6 5
3 4 U
6 1 L
2 5 L
1 6 U
4 3 U
6 2
3 4 U
6 1 L
10 10
5 6 U
4 7 U
8 3 L
8 3 L
1 10 U
9 2 U
10 1 L
10 1 L
8 3 U
8 3 U
6
7
3
0
10
2
1
0
0
0
*/
public class chocolate
{
public static void main(String[] arg)
{
new chocolate();
}
public chocolate()
{
FastScanner i... | JAVA |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n, q;
const int N = (1 << 20) + 2, MOD = 1000000007LL;
void max_self(int &x, int y) { x = max(x, y); }
struct node {
int lazy{}, val{};
node *left{}, *right{};
void extend() {
if (left == nullptr) {
left = new node();
right = new node();
}
}
... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | import java.util.Scanner;
import java.util.TreeSet;
public class Main
{
static private int n;
static private int q;
static private TreeSet<Area> set = new TreeSet<Area>();
static private TreeSet<Integer> used = new TreeSet<Integer>();
private static class Area implements Comparable<Area>
{
public int uBoun... | JAVA |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n, q, p, x, y;
map<int, pair<char, int> > m;
int qq() {
char c;
scanf("%d%d %c", &x, &y, &c);
map<int, pair<char, int> >::iterator b = m.lower_bound(x);
if (b->first == x) return 0;
if (c == 'L') --b;
int ans = abs(b->first - x);
if (b->second.first == c) ... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n, m, ans;
map<int, pair<char, int> > Map;
map<int, pair<char, int> >::iterator it;
char c[20];
inline int abs(int a) { return a > 0 ? a : -a; }
int main() {
int i, x, y;
scanf("%d %d", &n, &m);
Map[0] = {'U', 0};
Map[n + 1] = {'L', 0};
while (m--) {
scanf... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
set<pair<int, int> > st;
set<pair<int, int> >::iterator it;
int n, q;
char ch[5];
int x[N], y[N];
int main() {
scanf("%d%d", &n, &q);
st.insert(make_pair(0, 0));
st.insert(make_pair(n + 1, q + 1));
for (int i = 1; i <= q; i++) {
scanf("%d%... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 200000 + 5;
map<int, int> mp;
map<int, int>::iterator it;
int res[MAXN];
char oper[MAXN];
int n, m, x;
int main() {
scanf("%d%d", &n, &m);
memset(res, 0, sizeof res);
mp[0] = 0, mp[n + 1] = m + 1;
oper[0] = 'U', oper[m + 1] = 'L';
res[0] = 0, res[... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
struct node {
int l, r;
int num;
} Treex[4000009], Treey[4000009];
map<int, int> vis;
int i;
int tot = 1;
int Tot = 1;
int x, y;
char str[5];
void update_y(int ll, int rr, int c, int l, int r, int t) {
if (ll <= l && r <= rr)
Treey[t].num = max(Treey[t].num, c);
... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int TOUR = 1 << 30;
struct node {
int maxx, prop;
node *l, *r;
node(int _maxx, int _prop, node *_l, node *_r)
: maxx(_maxx), prop(_prop), l(_l), r(_r) {}
node() {}
};
struct tour {
node *NIL, *root;
tour() {
NIL = new node(0, 0, NIL, NIL);
NI... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int N = 300010;
const int nbits = 31;
const int blocks = 170;
int n, q, x[N], y[N], x1[N], variable1[N], tmin[4 * N], tmax[4 * N],
tupd1[4 * N], tupd2[4 * N], ts[N];
char t[N];
pair<int, int> p1[N], p2[N];
bool used[N];
void pushMax(int v) {
... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > s;
map<int, int> mp;
int n, q;
int main() {
scanf("%d%d", &n, &q);
s.insert(make_pair(0, 1));
s.insert(make_pair(n + 1, 0));
for (; q--;) {
int x, y;
char c;
scanf("%d%d %c", &x, &y, &c);
if (mp.count(x)) {
printf("0\n");
... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | /**
* @author Juan Sebastian Beltran Rojas
* @mail jsbeltran.valhalla@gmail.com
* @veredict No enviado
* @problemId CF555C
* @problemName Case of Chocolate
* @judge http://codeforces.com/
* @category segment tree
* @level medium
* @date 1/7/2015
**/
import java.io.*;
import java.util.*;
import static java.la... | JAVA |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
struct node {
int a, x, y;
node(){};
node(int A, int X, int Y) {
a = A;
x = X;
y = Y;
}
bool operator<(const node t) const { return a < t.a; }
};
int i, n, q;
set<node> s;
int main() {
ios::sync_with_stdio(0);
cin >> n >> q;
s.insert(node(0, 0, 0... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | //package round310;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
public class C {
InputStream is;
PrintWriter out;
String I... | JAVA |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | //package CF;
import java.io.*;
import java.util.*;
public class E {
static class SegmentTree { // 1-based DS, OOP
int N; //the number of elements in the array as a power of 2 (i.e. after padding)
int sTree[][];
SegmentTree(int in)
{
N = in;
sTree = new int[N<<1][2]; //no. of nodes = 2*N - 1... | JAVA |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | import java.util.Scanner;
import java.util.TreeSet;
public class P556E {
static long get_val(TreeSet<LPair> map, long query){
return map.ceiling(new LPair(query,0)).h - query + 1;
}
static boolean has_val(TreeSet<LPair> map, long query){
return map.contains(new LPair(query,0));
}
static void print_map(T... | JAVA |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
struct Node {
int s, e;
int u, l;
Node() {}
Node(int s, int e, int u, int l) : s(s), e(e), u(u), l(l) {}
friend bool operator<(const Node A, const Node B) {
return A.s == B.s
? (A.e == B.e ? (A.u == B.u ? A.l < B.l : A.u < B.u) : A.e < B.e)
... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | import java.io.*;
import java.util.*;
public class C{
public static boolean DEBUG = false;
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
StringTokenizer st;
st = getst(br);
... | JAVA |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | import java.io.*;
import static java.lang.Math.*;
import java.util.*;
import java.util.function.*;
import java.lang.*;
public class Main {
final static boolean debug = false;
final static String fileName = "";
final static boolean useFiles = false;
public static void main(String[] args) throws FileNot... | JAVA |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const double EPS = -1e8;
const double Pi = acos(-1);
bool inline equ(double a, double b) { return fabs(a - b) < EPS; }
const int MAXN = 200010;
int n, q;
set<tuple<int, int, int> > bst;
int qryl(int x, int y) {
auto it = bst.lower_bound(make_tuple(x, -1, -1));
if (it ==... | CPP |
555_C. Case of Chocolate | Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ... | 2 | 9 |
import java.util.*;
import java.io.*;
public class CaseOfChocolate555C {
static Random rd = new Random();
static int n;
static class Node {
int from, to, up, left;
Node lchild, rchild;
public Node(int a, int b, int c, int d) {
this.from = a;
this.to = 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())
hs = list(map(int, input().split()))
maxx = 0
ans = []
for h in reversed(hs):
if h > maxx:
ans.append(0)
else:
ans.append(maxx-h+1)
maxx = max(maxx, h)
print(' '.join(map(str, reversed(ans)))) | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | # from sys import stdout
from bisect import bisect_left as bs
from math import log as lg
from math import factorial as f
log = lambda *x: print(*x)
def cin(*fn, def_fn=str):
i,r = 0,[]
if fn: def_fn=fn[0]
for c in input().split(' '):
r+=[(fn[i] if len(fn)>i else def_fn) (c)]
i+=1
return r
######################... | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.util.Scanner;
import java.math.BigDecimal;
//import java.math.BigInteger;
public class Main{
public static void main(String[] args)
{ Scanner scan= new Scanner(System.in);
int num,b,temp;
int[] arr=new int[100001];
int[] adder=new int[100001];
num=scan.nextInt();
for(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 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int INF = 0x7FFFFFFF;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = 2 * acos(0.0);
const int maxn = 1e5 + 1666;
long long maxval[maxn << 2], mmax, aa[maxn], len;
void PushUp(int rt) { maxval[... | 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 | var numeric = readline(),
floor = readline().split(' '),
result = [0];
for (; floor.length > 1; ) {
var last_floor = +floor[floor.length - 1],
prev_floor = +floor[floor.length - 2];
if (prev_floor > last_floor) {
result.unshift(0);
floor.splice(floor.length - 1, 1);
} else {
if (last_floor === prev_f... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | from collections import Counter
n=int(input())
a=[int(x) for x in input().split()]
ra=a[::-1]
mx=[ra[0]]
c=Counter(a)
for i in range(1,n):
mx.append(max(mx[i-1], ra[i]))
for i in range(n):
if mx[n-1-i]==a[i]:
if c[a[i]]>1:
print(1, end=" ")
else:
print(0, end=" ")
else:
print(mx[n-1-i]+1-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 | n=input()
a=map(int,raw_input().split())
m=[0]*n
m[n-1]=a[n-1]
for i in xrange(n-2,-1,-1):
m[i]=max(m[i+1],a[i])
ans=[0]*n
for i in xrange(n-1):
ans[i]=max(0,m[i+1]+1-a[i])
ans[n-1]=0
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 | /* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc = 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 n;
scanf("%I64d", &n);
vector<long long> a(n), mx(n + 1, 0);
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
for (int i = n - 1; i >= 0; i--) mx[i] = max(mx[i + 1], a[i]);
for (int i = 0; i < n; i++)
if (a[i] <= mx[i + 1])
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 |
import java.util.*;
import java.io.*;
/**
*
* @author ringod
*/
public class ACM {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
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;
class node {
public:
long long int second;
long long int length;
};
void FastIO() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
int main() {
FastIO();
long long int n, i;
cin >> n;
long long int a[n], ans[n];
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;
const int INF = ~0U >> 1;
const double eps = 1e-6;
const long double PI = acos(0.0) * 2.0;
const int N = 5 + 100000;
long long int a[N], dp[N];
int main() {
int n;
while (scanf("%d", &n) == 1) {
for (int i = 0; i < n; i++) scanf("%I64d", &a[i]);
dp[n - 1] = 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 | import java.util.Scanner;
import java.util.ArrayList;
public class omar {
public static void main(String[] args) {
Scanner user_input = new Scanner(System.in);
ArrayList<Integer>omar=new ArrayList();
int x=user_input.nextInt();
int k[]=new int[x];
for(int i=0;i<x;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(raw_input())
h = [int(x) for x in raw_input().split()]
maxr = [0] * n
add = [0] * n
i = n-2
while i >= 0:
maxr[i] = max(maxr[i+1], h[i+1])
add[i] = max(0, maxr[i] - h[i] + 1)
i -= 1
result = ' '.join([str(item) for item in add])
result = result.strip()
print result
| 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 | #
# _,add8ba,
# ,d888888888b,
# d8888888888888b _,ad8ba,_
# d888888888888888) ,d888888888b,
# I8888888888888888 _________ ,8888888888888b... | 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()
l=[int(i)for i in raw_input().split()]
r=[l[-1]]
for i in xrange(n-2):
r.append(max(l[-2-i],r[-1]))
print ' '.join(['0' if l[i]>r[-1-i] else str(r[-1-i]-l[i]+1) for i in xrange(n-1)]),'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 | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> vec;
vector<int> res;
int n;
cin >> n;
while (n--) {
int a;
cin >> a;
vec.push_back(a);
}
int max = 0;
res.resize(vec.size());
for (int i = vec.size() - 1; i >= 0; i--) {
if (vec[i] > max) {
res[i] = 0;
... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = input()
ar = map(int,raw_input().split())
ar.reverse()
ans = [0]
m = ar[0]
for i in ar[1:]:
if i==m:
ans.append(1)
elif i>m:
ans.append(0)
m = i
else:
ans.append(m+1-i)
ans.reverse()
print " ".join(str(i) for i 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(raw_input())
l = [int(x) for x in raw_input().split()]
last = 0
ret = []
for i in xrange(n):
ret.append(str(max(0, last+1-l[n-1-i])))
last = max(last, l[n-1-i])
print " ".join(ret[::-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.Arrays;
import java.util.Scanner;
public class floors {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int a[]=new int[n];
int b[]=new int[n];
int c[]=new int[n];
for(int i=0;i<n;i++)
{
a[i]=sc.nextInt();
}
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.*;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[n];
int max =0,index=0;
for(int i=0;i<n;i++){
arr[i] = sc.nextInt();
if(arr[i]>=max){
max... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 |
n = int(input())
houses = list(map(int,input().split()))
lis = [0]*n
mx = 0
for i in range(n-1,-1,-1):
if houses[i] > mx:
mx = houses[i]
else:
lis[i] = mx - houses[i] + 1
print (*lis)
| 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()]
pref= [0]*n
from collections import defaultdict
d = defaultdict(int)
pref[-1] = a[-1]
d[pref[-1]]=n-1
for i in range(n-2,-1,-1):
pref[i] = max(pref[i+1],a[i])
if d[pref[i]]==0:
d[pref[i]]=i
#print(pref)
#print(d)
out = [0]*n
for i in range(n):
... | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = int(input())
h = list(map(int, input().split())) + [0]
h_max = [0] * (n + 1)
for i in range(n - 1, 0,-1):
h_max[i-1] = max(h_max[i], h[i] + 1)
res = []
for i in range(n):
res.append(str(max(h_max[i] - h[i], 0)))
print(" ".join(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()))
r = [0]
m = h[-1]
for i in range(n-2,-1,-1):
if h[i] <= m:
r.append(m + 1 - h[i])
else:
r.append(0)
m = h[i]
for i in range(n - 1,-1,-1):
print(r[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 main() {
int n;
cin >> n;
long long arr[n];
for (int a = 0; a < n; a++) {
cin >> arr[a];
}
long long max = arr[n - 1];
arr[n - 1] = 0;
for (int a = n - 2; a >= 0; a--) {
if (max < arr[a]) {
max = arr[a];
arr[a] = 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 | a = int(input())
b = list(map(int, input().split()))
mark = 0
answer = list()
for x in range(a):
if b[a - x - 1] > mark:
answer.append(0)
mark = b[a - x - 1]
else:
answer.append(mark - b[a - x - 1] + 1)
for x in range(a):
print(answer[a - x - 1]) | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n = input()
h = map(int, raw_input().split())
res = [0] * n
tmp = h[n - 1]
for i in xrange(n - 2, -1, -1):
if h[i] <= tmp:
res[i] = tmp - h[i] + 1
else:
res[i] = 0
tmp = h[i]
ans = ""
for i in res:
ans += str(i) + " "
print 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 | from sys import stdin, stdout
input = stdin.readline
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
m=a[n-1]-1
for i in range(n-1,-1,-1):
if(a[i]<=m):
b[i]=m-a[i]+1
else:
m=a[i]
b[i]=0
print(" ".join(map(str,b)),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 main() {
int n;
cin >> n;
int s[n];
for (int i = 0; i < (n); i++) cin >> s[i];
int b[n], x;
b[n - 1] = 0;
x = s[n - 1];
for (int i = (n - 2); i >= 0; i--) {
if (x == s[i])
b[i] = 1;
else if (x > s[i])
b[i] = (x - s[i] + 1);
else
... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.util.*;
import java.io.*;
public class yahia {
public static void main (String [] Yahia_Mostafa) throws Exception {
Scanner sc =new Scanner(System.in);
int n=sc.nextInt();
int [] x=new int [n];
TreeMap<Integer, Integer>tMap=new TreeMap<Integer, Integer>(Collections.reverseOrder());
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 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, max = -1;
cin >> n;
long long int a[n], b[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = n - 1; i >= 0; i--) {
if (max < a[i]) {
max = a[i];
b[n - i] = 0;
} else {
b[n - i] = max + 1 - 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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
*
* @author ramilagger
*/
public class Main {
public static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public ... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.math.BigInteger;
import java.util.Scanner;
public class ez {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] floors = new int[n];
for(int i =0; i < n; i++){
floors[i]=in.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 | 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 | n = int(input())
s = [int(i) for i in input().split()]
cnt = 0
m = 0
for i in range(n-1,-1,-1):
if s[i]>m:
m = s[i]
s[i]=0
else:
s[i]=m-s[i]+1
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>
const int MAXN = (int)10e5 + 5;
using namespace std;
int v[MAXN];
int maxH[MAXN];
int main() {
int N, h;
cin >> N;
for (int i = 0; i < N; i++) {
cin >> v[i];
}
int curMax = 0;
for (int i = N - 1; i >= 0; i--) {
curMax = max(curMax, v[i]);
maxH[i] = curMax;
}
for (int... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MX = 1e5 + 5;
int A[MX], ans[MX];
int main() {
int n;
while (~scanf("%d", &n)) {
for (int i = 1; i <= n; i++) {
scanf("%d", &A[i]);
}
ans[n] = 0;
int Max = A[n];
for (int i = n - 1; i >= 1; i--) {
ans[i] = Max + 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 i, n, temp = 0;
scanf("%d", &n);
int a[n], b[n];
for (i = 0; i < n; i++) scanf("%d", &a[i]);
for (i = n - 1; i >= 0; i--) {
if (a[i] > temp) {
temp = a[i];
b[i] = 0;
} else {
b[i] = temp - a[i] + 1;
}
}
for (i = 0... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n=int(input())
a=list(map(int,input().split()))
b=[0]*n
mx=a[n-1]
for i in range(n-2,-1,-1):
b[i]=max(0,mx-a[i]+1)
if a[i]>mx:mx=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 | __author__ = 'Devesh Bajpai'
'''
https://codeforces.com/problemset/problem/581/B
Solution:
'''
def solve(n, h_arr):
h_increment = [0] * n
largest = h_arr[n-1]
for i in xrange(n-2, -1, -1):
if h_arr[i] <= largest:
h_increment[i] = largest - h_arr[i] + 1
else:
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())
arr = [int(x) for x in input().split()]
arr1 = [0]*n
m = arr[n-1]
for i in range(n-2,-1,-1):
if arr[i]<m:
arr1[i] = m-arr[i]+1
elif arr[i]==m:
arr1[i] = 1
else:
m = arr[i]
print(*arr1)
| PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import javax.swing.plaf.synth.SynthUI;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
public class d {
public static void main(String args[]) throws IOException {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader sc = new InputRea... | 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], r[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
r[n - 1] = n - 1;
for (int i = n - 2; i >= 0; i--) {
if (arr[i] > arr[r[i + 1]])
r[i] = i;
else
r[i] = r[i + 1];
}
for (int 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 | import sys
def solve():
n, = rv()
h, = rl(1)
maxsofar = 0
res = [0] * n
for i in range(n - 1, -1, -1):
if h[i] <= maxsofar:
res[i] = maxsofar - h[i] + 1
else:
maxsofar = h[i]
prt(res)
def prt(l): return print(' '.join(map(str, l)))
def rs(): return 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 | //package codeforces;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
i... | JAVA |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> street(N);
for (int i = 0; i < N; i++) {
cin >> street[i];
}
int max_floors = -1;
for (int i = N - 1; i >= 0; i--) {
int temp = max(0, max_floors - street[i] + 1);
max_floors = max(max_floors, street[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()))
a = []
if n==1:
print(0)
quit()
y = h[-1]
h[-1] = 0
for i in reversed(range(n-1)):
if h[i]>y:
y = max(h[i],y)
h[i] = 0
h[-1] = 0
else:
h[i] = (y-h[i]+1)
"""
tmp = h[-1]
for i in reversed(range(n-1)):
if h[i]<=t... | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, i, m, a[100001], b[100001];
int main() {
cin >> n;
for (i = 0; i < n; i++) cin >> a[i];
m = a[n - 1];
for (i = n - 2; i >= 0; i--) {
if (m >= a[i]) b[i] = m - a[i] + 1;
if (m < a[i]) m = a[i];
}
for (i = 0; i < n; i++) cout << b[i] << ' ';
}
| CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | n=int(input())
l=list(map(int,input().split()))
# l.reverse()
v=[]
# v.append(0)
ma=0
for i in range(n-1,-1,-1):
# print(l[i])
if l[i]>ma:
v.append(0)
ma=l[i]
# # continue
else:
v.append(max(0,ma-l[i]+1))
v.reverse()
print(*v) | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | readline();
var houses = readline().split(" ");
var max = -1, L = houses.length, result = [];
for (var i = L-1; i>=0; --i) {
var T = houses[i];
result.push(T > max ? 0 : max - T + 1);
max = Math.max(T, max);
}
result.reverse();
print(result.join(" "));
| 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())
heights = list(map(int, input().split()))
highest = 0
result = n * [0]
for i in range(len(heights) - 1, -1, -1):
if heights[i] <= highest:
result[i] = highest - heights[i] + 1
else:
highest = heights[i]
print(' '.join(map(str, result)))
| PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | import java.io.FileInputStream;
import java.io.InputStream;
import java.util.*;
public class Main {
public static boolean debug = false;
public static void main(String[] args) {
InputStream stream = System.in;
try {
if (debug) {
stream = new FileInputStream("test.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 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
vector<long long> v(n, 0);
for (long long i = 0; i < n; i++) {
cin >> v[i];
}
vector<long long> ans(n, 0);
ans[n - 1] = v[n - 1];
for (long long i = n - 2; i >= 0; i--) {
ans[i] = max<long long>(v[i], ans[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()[:n]))
m=0
ans=[0]*(n)
for i in range(n-1,-1,-1):
if (a[i]>m):
ans[i]=0
m=a[i]
else:
ans[i]=m-a[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 | n = int(input());
l = list(map(int, input().split()));
ans = n * [0];
ma = 0; i = n - 1;
while(i >= 0):
if(l[i] <= ma):
ans[i] = ma - l[i] + 1;
else:
ans[i] = 0;
ma = l[i];
i -= 1;
for i in range(n):
print(str(ans[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 main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
vector<int> s(n, 0);
s[n - 1] = a[n - 1];
for (int i = n - 2; i >= 0; i--) s[i] = max(a[i], s[i + 1]);
for (int i = 0; i < n - 1; i++) cout << max(0, s[i + 1] - a[i] + 1... | CPP |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, x;
int f[200100], nn[200100];
int mi(int a, int b) { return a < b ? a : b; }
int ma(int a, int b) { return a > b ? a : b; }
int main() {
scanf("%d", &n);
int h = 0;
for (int i = 1; i <= n; i++) {
scanf("%d", &f[i]);
}
for (int i = n; i >= 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 |
input()
H = [int(x) for x in input().split(' ')]
T = []
mx = H[-1]
for i, e in enumerate(H):
j = len(H)-i-1
if j == len(H)-1:
T.append(0)
else:
h = mx-H[j]
if h >= 0:
T.append(h+1)
else:
T.append(0)
mx = max(mx, H[j])
for i, x in enumerate(T... | PYTHON3 |
581_B. Luxurious Houses | The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all... | 2 | 8 | __author__ = 'User'
n = int(input())
arr = list(map(int, input().split()))
mx = [0] * (n + 1)
for i in range(n - 1, -1, -1):
#print(arr[i], mx[i + 1])
mx[i] = max(mx[i + 1], arr[i])
for j in range(n):
if mx[j + 1] >= arr[j]:
print(mx[j] - arr[j] + 1, end = " ")
else:
print(0, end = " ") | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.