Search is not available for this dataset
name
string
description
string
source
int64
difficulty
int64
solution
string
language
string
117_A. Elevator
And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator...
2
7
import static java.util.Arrays.*; import static java.lang.Math.*; import static java.math.BigInteger.*; import java.util.*; import java.math.*; import java.io.*; public class A implements Runnable { String file = "input"; boolean TEST = false; void solve() throws IOException { int n =...
JAVA
117_A. Elevator
And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator...
2
7
#include <bits/stdc++.h> using namespace std; void readInputData(); void run(); int main(int argc, char** argv) { ios_base::sync_with_stdio(false); readInputData(); run(); return 0; } int n; int m; void readInputData() { cin >> n >> m; } void run() { long long s; long long f; long long t; long long k; ...
CPP
117_A. Elevator
And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator...
2
7
import java.util.Scanner; public class Elevator { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int turn = 2 * (m - 1); while (n-- > 0) { int s = sc.nextInt(); ...
JAVA
117_A. Elevator
And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator...
2
7
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigDecimal; import java.math.BigInteger; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { InputReader in = new InputReader(); PrintWriter out = new PrintWrit...
JAVA
117_A. Elevator
And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator...
2
7
import java.io.*; import java.util.Scanner; import java.util.StringTokenizer; /** * Michael Gerasimenko * Date: 23.09.11 * Time: 18:48 */ public class Main { StringTokenizer tok = new StringTokenizer(""); public static void main(String[] args) throws FileNotFoundException { /* BufferedReader in...
JAVA
117_A. Elevator
And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator...
2
7
n, m = map(int, input().split()) k = 2 * (m - 1) p = [0] * n for i in range(n): s, f, t = map(int, input().split()) d = t % k if s < f: p[i] = (k if s <= d else 0) + f - 1 + t - d elif f < s: p[i] = (k if d + s > k + 1 else 0) + k + 1 - f + t - d else: p[i] = t print('\n'.join(map(str, p)))
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
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.InputStreamReader; import java.util.ArrayList; import java.util.TreeMap; import java.util.StringTokenizer; import java.util.Map; import java.io.BufferedReader; impo...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; int color[200010], Max[200010]; pair<int, int> p[200010]; int main() { int n, q; memset(color, -1, sizeof(color)); scanf("%d", &n); for (int i = 1; i <= n; i++) { int a; scanf("%d", &a); p[i] = make_pair(1, a); } scanf("%d", &q); for (int i = 1; i ...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<int> A(n); for (auto &a : A) cin >> a; int q; cin >> q; vector<vector<int>> Q; for (int i = 0; i < q; ++i) { int t; cin >> t; if (t == 1) { int p, x; ci...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long int n, q; vector<pair<long long int, pair<long long int, long long int>>> op; cin >> n; map<long long int, long long int> pres; long long int a[n + 5]; for (long long int i = 1; i < (n + 1); i++) cin >> a[i]; cin >> q; for (long long i...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; const int nax = 2e5 + 7; int a[nax]; pair<int, int> force[nax]; int t2m[nax]; bool f[nax]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, q, t, p, x; cin >> n; for (int i = 0; i < (int)(n); ++i) cin >> a[i]; cin >> q; memset(t2m, -1, sizeof t2m)...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.BitS...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
/* * @author derrick20 */ import java.io.*; import java.util.*; public class betterWelfareState { public static void main(String args[]) throws Exception { FastScanner sc = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); int N = sc.nextInt(); int[] mone...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; struct node { int l, r, val; node() {} node(int _l, int _r, int _v) { l = _l, r = _r, val = _v; } } t[maxn << 2]; int n, m, a[maxn]; void pushdown(int x) { t[x << 1].val = max(t[x].val, t[x << 1].val); t[x << 1 | 1].val = max(t[x].val, t[...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
n = int(input()) a = list(map(int,input().split())) mark=[1 for i in range(n)] query = [] q = int(input()) m = -1 for i in range(q): next = list(map(int,input().split())) if next[0]==2: m = max(m,next[1]) query.append(next) mx = 0 for i in range(n): if a[i]<m: a[i]=m for i in range(q-1,-...
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import sys input = sys.stdin.buffer.readline n = int(input()) a = list(map(int,input().split())) answers = [-1]*n last_all_update = [-1,0] updates = [[1,i+1,a[i]] for i in range(n)] q = int(input()) for i in range(1,q+1): updates.append(list(map(int,input().split()))) curr_mx = 0 for i in range(len(updates)-1,...
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n, Q, t, x, y; int A[N], T[N], P[N]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> A[i]; cin >> Q; for (int i = 0; i < Q; i++) { cin >> t; if (t == 1) { cin >> x >> y; x--; A[x] = y; T[x] = i; ...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
N = int(input()) List = [int(x) for x in input().split()] query = [] q = int(input()) for i in range(q): x = [int(x) for x in input().split()] query.append(x) second = [-1] * q if(query[q-1][0] == 2): second[q-1] = query[q-1][1] for i in range(q-2,-1,-1): if(query[i][0] == 2): second[i] = max(se...
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const double eps = 1e-8; const int INF = 0x3f3f3f3f; const int mod = 1e9 + 7; const int seed = 131; int n, a[maxn], q; struct node { int l, r, sum, lazy; } Q[maxn << 2]; void build(int rt, int l, int r) { Q[rt].l = l, Q[rt].r = r; if (l == r)...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
//package cf576d1; import java.io.*; import java.util.*; public class B { // ------------------------ public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); // ------------------------ int n=sc.nextInt(); int[]a=new int[n]; ...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
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.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.util.Objects; import java.util.List; i...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
n = int(input()) sp = list(map(int, input().split())) m = int(input()) pos = [-1] * (n + 1) m1 = 0 mem = [] for i in range(m): sp1 = list(map(int, input().split())) mem.append(sp1) if sp1[0] == 1: sp[sp1[1] - 1] = sp1[2] pos[sp1[1] - 1] = i else: m1 = max(m1, sp1[1]) ma...
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool upmin(T &x, T y) { return y < x ? x = y, 1 : 0; } template <typename T> inline bool upmax(T &x, T y) { return x < y ? x = y, 1 : 0; } const long double eps = 1e-11; const long double pi = acos(-1); const int oo = 1 << 30; const long lon...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> std::mt19937 rng( (int)std::chrono::steady_clock::now().time_since_epoch().count()); const int ms = 200200; int bit[ms]; int qry(int x) { int ans = 0; for (; x < ms; x += x & -x) { ans = std::max(ans, bit[x]); } return ans; } void upd(int x, int v) { for (; x > 0; x -= x & -x)...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; void initialize(long long arr[], long long n) { for (long long i = 0; i < n; i++) { arr[i] = -1; } } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, q, store, x, c, a; cin >> n; long long arr[n + 1]; long long oper...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.StringTokenizer; public class Main { private BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); private BufferedWriter...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.InputStreamReader; import java.util.*; import java.io.BufferedReader; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(S...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
from collections import deque, defaultdict from math import sqrt, ceil,factorial,floor import sys import copy def get_array(): return list(map(int, sys.stdin.readline().strip().split())) def get_ints(): return map(int, sys.stdin.readline().strip().split()) def input(): return sys.stdin.readline().strip() maxn=(10**5)+...
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; const long long N = 200005; long long a[N], tree[N * 4], modif[N], quer[N]; void build(long long node, long long l, long long r) { if (l == r) { tree[node] = modif[l]; return; } long long mid = (l + r) / 2; build(node * 2, l, mid); build(node * 2 + 1, mid ...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; int arr[1000000], temp[1000000], b[1000000]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> arr[i]; int q; cin >> q; int a; for (int i = 0; i < q; i++) { cin >> a; if (a == 1) { int hi1, hi2; cin >> hi1 >> hi2; arr[...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2") using namespace std; const int INF = 1000 * 1000 * 1000 + 7; const long long LINF = 1LL * INF * INF; const int MAX = 1e5 + 7; const double PI = acos(-1.); const double EPS = 1e-7; const int MOD = 998244353; in...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> const int N = 2e5; int n, q; int Suf[N + 5]; struct Node { int Val, Time; } R[N + 5]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &R[i].Val); scanf("%d", &q); for (int i = 1; i <= q; ++i) { int opt, p, x; scanf("%d", &opt); if (opt & 1) { s...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
n = int(input().strip()) a = list(map(int, input().split())) q = int(input().strip()) queries = [] last_balance = [-1]*n last_balance_id = [-1]*n for i in range(q): query = list(map(int, input().split())) queries.append(query) if query[0]==1: p = query[1]-1 last_balance[p] = query[2] ...
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; int n, a[400100], Suff[400100], Query[400100], q; vector<pair<int, int> > v[400100]; int main() { memset(Query, -1, sizeof(Query)); cin >> n; for (int i = 1; i <= n; i++) scanf("%d", &a[i]); cin >> q; for (int i = 1; i <= q; i++) { int type, p, x; scanf("%...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
n = int(input()) a = list(map(int,input().split())) q = int(input()) last = [0 for i in range(n+1)] ubah = [0 for i in range(q+1)] for i in range(1,q+1): k = input().split() if k[0] == '1': p = int(k[1]) x = int(k[2]) a[p-1] = x last[p-1] = i else: x = int(k[1]) ...
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; const int MAX_N = 101; const int MOD = 1e9 + 7; const int INF = 1e9; const long long LINF = 1e18; void solve() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } int q; cin >> q; vector<int> next(n); vector<int> queries; ...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class Main { private static final String NO = "NO"; private static final String YES = "YES"; InputStream is; PrintWriter...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> bool comp(const int& a, const int& b) { return a < b ? false : true; } using namespace std; long long int a[200009]; int tim[200009]; vector<long long int> a1; vector<int> a2; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) { ...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; struct node { int v, l, r, lz; } tr[200010 << 2]; void build(int rt, int l, int r) { tr[rt].l = l; tr[rt].r = r; tr[rt].lz = 0; if (l == r) { scanf("%d", &tr[rt].v); return; } int mid = l + r >> 1; build(rt * 2, l, mid); build(rt * 2 + 1, mid + 1, ...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
R=lambda:map(int,input().split()) n=int(input()) a=*zip([1]*n,range(1,n+1),R()),*([*R()]for _ in[0]*int(input())) r=[-1]*n m=0 for t,p,*x in a[::-1]: if t>1:m=max(m,p) elif r[p-1]<0:r[p-1]=max(x[0],m) print(*r)
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.*; import java.util.*; import java.lang.Math; public class Main { static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); st = new S...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int q; cin >> q; vector<vector<int> > v(q); int x1, x2, x3; for (int i = 0; i < q; i++) { cin >> x1; v[i].push_back(x1); if (x1 == 1) { cin >> x2 >> x3; ...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; using ll = long long; inline int read(); const int M = 500016, MOD = 1000000007; int save[M], lst[M]; int lim[M]; int main(void) { int n = read(); for (int i = 1; i <= n; ++i) { save[i] = read(); } int q = read(); for (int id = 1; id <= q; ++id) { int op =...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.*; import java.util.*; public class A { static FastReader f = new FastReader(); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) { int n = f.nextInt(); Pair[] pairs = new Pair[n]; for(int i=0;i<n;i++) { pairs[i]...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const long long mod = 998244353; long long n, q, num[200005], payout[200005], dfn[200005], flag, a, b; long long st[200005][40]; void build_st(long long num[], long long n) { for (long long i = 1; i <= n; i++) st[i][0] = num[i]; long long LC = (l...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; long long n, a[200100], q, b[200100], x[200100]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; long u, v, w; cin >> q; for (int i = 1; i <= q; i++) { cin >> u; if (u == 2) { cin >> v; b[i] = v; } else { cin >> v >> ...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; const long long MOD = (1e9) + 7; const long double EPS = 0.0000001; const int N = 200000 + 5000; long long lst[N]; long long tree[4 * N]; long long arr[N]; long long query(int node, int l, int r, int a, int b) { if (l > r || a > b || l > b || r < a) return 0; if (a <= l...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import sys read = sys.stdin.readline n = int(read()) balance = list(map(int, read().split(" "))) n_operations = int(read()) minis = [] next_mini = 0 changed_before = [0] * (len(balance)+1) for n_op in range(n_operations): operation = list(map(int, read().split(" "))) if operation[0] == 1: x = operat...
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; inline int Max(int A, int B) { return A > B ? A : B; } int n, a[200005], op[200005], pp[200005], xx[200005], mx[200005]; struct data { int id; int v; int tm; inline const bool operator<(const data &B) const { return v > B.v; } } st[200005]; inline bool cmp(data &A, ...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.*; import java.util.*; import java.util.Map.Entry; public class byo { 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[] array, sTree, lazy; SegmentTree(int[] in) { array = in; N = in.length - 1; ...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
// This template code suggested by KT BYTE Computer Science Academy // for use in reading and writing files for USACO problems. // https://content.ktbyte.com/problem.java import java.util.*; import java.io.*; public class WelfareState { static StreamTokenizer in; static int nextInt() throws IOException {...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.math.*; public class Main{ static ArrayList a[]=new ArrayList[200001]; public void solve () { InputReader in = new InputReader(System.in); PrintWriter pw = new PrintWriter(System.out); int n=in.nextInt(); ...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.util.Scanner; import java.util.ArrayList; public class D_WellFare{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; int[] Stat = new int[n]; for (int i = 0 ; i < n ; i++) a[i] = sc.nextInt(); int q = sc.nextInt(); in...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.UncheckedIOException; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; public class water { public static void main(String[] args) { InputStream inputStream = System.in; ...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n]; int q; for (int i = 0; i < n; i++) { cin >> arr[i]; } cin >> q; vector<pair<int, pair<int, int> > > X(q, make_pair(-1, make_pair(-1, -1))); for (int i = 0; i < q; i++) { cin >> X[i].first; if (X[i].firs...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; const long long INF = 1e9 + 5; const long long mod = 1e9 + 7; const int tx[] = {1, -1, 0, 0}, ty[] = {0, 0, 1, -1}; const int bs = 31; int n, q, a[N], lst[N]; vector<int> vec; int ct; int t[N * 4]; void upd(int v, int L, int R, int pos, int val) { i...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; int const INF = (int)1e9 + 1e3; long long const INFL = (long long)1e18 + 1e6; mt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count()); uniform_int_distribution<long long> ll_distr; long long rnd(long long a, long long b) { return ll_distr(tw) % (b - a ...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5; class SegmentTree { int ar[MAXN * 3]; void Add(int l, int r, int l1, int r1, int index, int value) { if (l == l1 && r == r1) { ar[index] = max(ar[index], value); return; } int med = (l + r) / 2; if (l1 <= med) Add(l, med...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.util.*; import java.io.*; public class WelfareState { public static void main(String[] args) { FastScanner scanner = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int n = scanner.nextInt(); //Probably pq useful and remove as type 1 are executed ...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { FastInput in = new FastInput(new InputStreamReader(System.in)); int N = in.nextInt(); int[] arr = new int[N + 1]; int[] last = new int[N + 1]; int[] val = ne...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.util.*; import java.lang.*; import java.io.*; public class Main { PrintWriter out = new PrintWriter(System.out); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok = new StringTokenizer(""); String next() throws IOException { if (!tok.hasMoreToke...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
from sys import stdin input = stdin.readline if __name__ == '__main__': n = int(input()) arr = list(map(lambda o: (o, 0), map(int, input().split()))) q = int(input()) parr = [] for i in range(q): e = input().split() if e[0] == '1': arr[int(e[1]) - 1] = (int(e[2]), i)...
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; int mod = 1000000007; const int inf = 1034567891; const long long LL_INF = 1234567890123456789ll; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; } template <typename Arg1, typename... Args> void __f(const char* na...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Aman Kumar Singh */ public class Main ...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.util.*; import java.io.*; import java.lang.*; import java.math.*; public class B { public static void main(String[] args) throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new Out...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 200010; int n, m, a[N]; int tr[N * 4]; void build(int u, int l, int r) { if (l >= r) { tr[u] = a[l]; return; } int mid = (l + r) >> 1; build(u * 2, l, mid), build(u * 2 + 1, mid + 1, r); } void mdy(int u, int l, int r, int x, int w) { if (l >...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
from sys import stdin from sys import setrecursionlimit as SRL; SRL(10**7) rd = stdin.readline rrd = lambda: map(int, rd().strip().split()) n = int(input()) a = list(rrd()) op = [] q = int(input()) for i in range(q): c = list(rrd()) op.append(c) sure = [-1] * (n+1) hi = 0 for i in range(q-1,-1,-1): if...
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; const int MAXN = 200005; int n, q, p, x, a[MAXN], b[MAXN], c[MAXN], o; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; cin >> q; for (int i = 1; i <= q; i++) { cin >> o; if (o == 1) { cin >> p >> x; c[p] = i, a[p] = x; } else...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; int a[200005], p[200005], t[200005]; int main() { int T; int n, m; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); scanf("%d", &m); int ans = 0; for (int i = 1; i <= m; i++) { int op, x, y; scanf("%d", &op); if (op == 1) { s...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
R=lambda:map(int,input().split()) n=int(input()) a=*zip([1]*n,range(1,n+1),R()),*([*R()]for _ in[0]*int(input())) r=[-1]*n m=0 for t,*p in a[::-1]: if t>1:m=max(m,p[0]) elif r[p[0]-1]<0:r[p[0]-1]=max(p[1], m) print(*r)
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#!/usr/bin/env python from __future__ import division, print_function import os import sys from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip import random import collections import math import itert...
PYTHON
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; long long int ops[200005]; long long int opsmoney[200005]; long long int money[200005]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> money[i]; } long long int q; cin >> q; memset(opsmoney, 0, sizeof(opsmoney)); memset(ops, 0, sizeof...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import sys input = sys.stdin.readline I = lambda : list(map(int,input().split())) n, = I() l=I() q,=I() ar=[-1]*n tm=0 qr=[] for i in range(q): qr.append(I()) for i in range(q-1,-1,-1): r=qr[i] if r[0]==1: if ar[r[1]-1]==-1: ar[r[1]-1]=max(r[2],tm) else: tm=max(tm,r[1]) for i in range(n): l[i] = max(tm,l[i...
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.*; import java.util.*; public class TaskD { void run() { FastReader in = new FastReader(System.in); // FastReader in = new FastReader(new FileInputStream("input.txt")); PrintWriter out = new PrintWriter(System.out); // PrintWriter out = new PrintWriter(new FileOutputSt...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; int a[N]; int n, m; int t[N]; int t1[N]; int MAX[N]; struct Node { int t, v; Node(int t = 0, int v = 0) : t(t), v(v) {} } pp[N]; int main() { scanf("%d", &n); int tot = 0; for (int i = 1; i <= n; i++) scanf("%d", &a[i]); scanf("%d", &m); ...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashSet; import java.util.StringTokenizer; public class WEl { static class FastReader { BufferedReader br; StringTok...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Set; import java.util.StringTokenizer; public class TaskD { public static void main(String[] arg) { final FastScanner in = new FastScanner(System.in);...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
from collections import deque n = int(input()) money = list(map(int, input().split())) money_t = [0]*len(money) # moments of last money change x_list = [] # subsidion of government # processing queries q = int(input()) for q_ind in range(q): line = list(map(int, input().split())) if line[0] == 2: x = ...
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; int n, q, y, x, z, mx, c2 = 0; pair<int, int> a[200001], tt, us[200001]; int tp[200001]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i].first; a[i].second = 0; } cin >> q; tp[0] = -1; for (...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
n = int(input()) a = list(map(int, input().split())) q = int(input()) qu = list() an = [-1]*n m = 0 for i in range(q): qu.append(tuple(map(int, input().split()))) for i in range(q): if qu[q-i-1][0] == 2: m = max(m, qu[q-i-1][1]) else: if an[qu[q-i-1][1]-1] == -1: an[qu[q-i-1][1]-...
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 200000 + 10; int x[N], mx[N], last[N]; inline void read(int &x) { x = 0; int f = 1; char s = getchar(); while (s < '0' || s > '9') { if (s == '-') f = 0; s = getchar(); } while (s >= '0' && s <= '9') { x = (x << 1) + (x << 3) + (s ^ 48)...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3") using namespace std; int m_suf[200001] = {}; int a[200001]; bool used[200001] = {}; struct query { int i, p, x; query(int i, int x) : i(i), p(0), x(x){}; query(int i, int p, int x) : i(i), p(p), x(x){}; query() : i(0), p(0), x(0){}; ...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.*; import java.util.*; public class D_WelfareState { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader inp = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); ...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws java.lang.Exception { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(out...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.*; import java.util.Collections; import java.util.LinkedList; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.nextI...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.*; import java.nio.CharBuffer; import java.util.NoSuchElementException; public class P1199D_2 { public static void main(String[] args) { SimpleScanner scanner = new SimpleScanner(System.in); PrintWriter writer = new PrintWriter(System.out); int n = scanner.nextInt(); ...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.util.*; public class TestClass{ public static void main(String args[]) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int arr[] = new int[n+1]; for(int i =0;i<n;i++) arr[i+1]= in.nextInt(); int q = in.nextInt(); int query[] = new int[q+1]; int ...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; const int N = (int)2e5 + 100; int t[4 * N]; vector<int> v; void build(int node, int l, int r) { if (l == r) t[node] = v[l]; else { int m = (l + r) / 2; build(node * 2, l, m); build(node * 2 + 1, m + 1, r); t[node] = max(t[node * 2], t[node * 2 + 1]);...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; int rawData[(int)(2e5 + 10)]; pair<int, int> data[(int)(2e5 + 10)]; int c[(int)(2e5 + 10)]; int remx[(int)(2e5 + 10)]; int ind = 0; int Tree[(int)(2e5 + 10) * 4]; int build(int v, int l, int r) { if (l == r) return Tree[v] = remx[l]; int middle = (l + r) / 2; return T...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.util.*; import java.io.*; import java.math.*; public class Main { public static void process()throws IOException { int n=ni(),arr[]=new int[n+1]; for(int i=1;i<=n;i++) arr[i]=ni(); int q=ni(),query_no_2[]=new int[q+1],query_no_1[]=new int[n+1]; for(int i=1;i<=q;i++...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; using ull = unsigned long long; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<pair<int, int>> vec(n, {0, 0}); for (auto &p : vec) cin >> p.first; int k; cin >> k; vector<int> mx; mx.reserve(k / 4); int t, id, ...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; int x[200009], u[20][200009]; int a[200009], t[200009]; int check(int l, int r) { int lev = 0; int ans = 0; while (l <= r) { if (l % 2 == 1) { ans = max(ans, u[lev][l]); l++; } if (r % 2 == 0) { ans = max(ans, u[lev][r]); r--; }...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
n=int(input()) ar=list(map(int,input().split())) q=int(input()) op=[-1]*n;m=0 pp=[] for i in range(q): pp.append(list(map(int,input().split()))) for i in range(q-1,-1,-1): if(pp[i][0]==2): m=max(m,pp[i][1]) else: if(op[pp[i][1]-1]==-1): op[pp[i][1]-1]=max(pp[i][2],m) for i in ran...
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.*; import java.util.ArrayList; import java.util.Collections; public class B1198 { public static void main(String[] args) throws IOException{ BufferedReader inp = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(Sy...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.io.*; import java.util.*; public class Solution { static Scanner sc=new Scanner(System.in); static PrintWriter out=new PrintWriter(System.out); //debug static void debug(Object... o) { System.out.println(Arrays.deepToString(o)); } //Main public static void main(String args[]) { int test=...
JAVA
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; long long last[200005], maxi[200005]; void solve() { long long n, q, type, p, x, i; cin >> n; vector<long long> v(n); for (i = 0; i < n; i++) { cin >> v[i]; } cin >> q; for (i = 0; i < q; i++) { cin >> type; if (type == 1) { cin >> p >> x; ...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; struct rich { int x, y; } a[200005]; int b[200005]; int read() { int A; bool K; char C; C = A = K = 0; while (C < '0' || C > '9') K |= C == '-', C = getchar(); while (C > '/' && C < ':') A = (A << 3) + (A << 1) + (C ^ 48), C = getchar(); return (K ? -A : A);...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import sys input=sys.stdin.readline n=int(input()) ar=list(map(int,input().split())) q=int(input()) op=[-1]*n;m=0 pp=[] for i in range(q): pp.append(list(map(int,input().split()))) for i in range(q-1,-1,-1): if(pp[i][0]==2): m=max(m,pp[i][1]) else: if(op[pp[i][1]-1]==-1): op[pp[i...
PYTHON3
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; struct cmp { bool operator()(const pair<long long, long long> &a, const pair<long long, long long> &b) const { return a.first - a.second + 1 > b.first - b.second + 1; } }; void solve() { long long n; cin >> n; v...
CPP
1198_B. Welfare State
There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the governm...
2
8
import java.util.Arrays; import java.util.Scanner; import java.util.stream.Collectors; public class Main { 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 < a.length; i++) { a[i] = sc.nextInt(); } int q = sc.ne...
JAVA