description
stringlengths
35
9.39k
solution
stringlengths
7
465k
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; template <typename T> void __read(T& a) { cin >> a; } template <typename T, typename... Args> void __read(T& a, Args&... args) { cin >> a; __read(args...); } constexpr long long M7 = 1000000007ll; constexpr long long M9 = 1000000009ll; constexpr long long MFFT = 99824...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const int N = 100005; int dr8[] = {0, 0, 1, -1, 1, 1, -1, -1}; int dc8[] = {1, -1, 0, 0, -1, 1, -1, 1}; int dr4[] = {0, 1, -1, 0}; int dc4[] = {1, 0, 0, -1}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t-...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.*; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.StringTokenizer; import static java.lang.Math.max; import static java.lang.Math.min; public class Main { void run() throws IOException { int t = nextI...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const int N = 2 * 1e5 + 1; struct Emp { int l, r; } emp[N]; bool search(int m, int n, long long s) { long long sum = 0, cnt = 0; for (int i = n - 1; i >= 0; i--) { if (emp[i].l >= m) cnt++; else if (emp[i].l <= m && emp[i].r >= m && cnt <= n / 2) { ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Scanner; public class D1251 { static int n; static Seg[] arr; public static void main(String[] args){ int t; Scanner sc = new Scanner(System.in); t = sc.nextInt(); w...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; int n; int T, l, r, ans, mid; pair<int, int> a[maxn]; int todo[maxn], top; long long s; bool check(int mid) { long long ss = s; int tot = 0, top = 0; for (int i = 0; i < n; i++) { if (a[i].second >= mid) { if (a[i].first >= mid) ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; long long n, second; long long minS = 0; vector<int> ptats; vector<pair<int, int>> lr; bool check(long long median) { long long excess = 0; int it = upper_bound(ptats.begin(), ptats.end(), median) - ptats.begin() - 1; int left = it; int right = (n - it - 1); if (l...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; long long add(long long a, long long b, long long mod) { return (a % mod + b % mod) % mod; } long long sub(long long a, long long b, long long mod) { return (a % mod - b % mod + mod) % mod; } long long mul(long long a, long long b, long long mod) { return ((a % mod) *...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Collection; import java.util.InputMismatchException; import java.io.IOException; import java.util.Random; import java.util.NoSuchElementException; import java.io.Inp...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.*; import java.util.*; public class Main { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); long sum=sc.nextLong(); Pair a[]=new Pair[n]; for( int i=0;i<n;i++) { a[i]=new P...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; long long n, s; vector<pair<int, int> > v; bool moze(int x) { long long temp = 0LL; int br = 0; vector<int> nz; for (int i = 0; i < n; ++i) { if (v[i].second < x) temp += v[i].first * 1LL; else if (v[i].first >= x) { temp += v[i].first * 1LL; ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; int l[200010], r[200010]; vector<long long> d; void solve() { long long n, s; scanf("%lld%lld", &n, &s); for (int i = 1; i <= n; i++) scanf("%lld%lld", &l[i], &r[i]); int L = 1, R = 1e9, m = (1 + n) / 2; long long sum0 = accumulate(l + 1, l + 1 + n, 0LL); while ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#!/usr/bin/python3 import array import math import os import sys def main(): T = read_int() for _ in range(T): N, S = read_ints() A = [read_ints() for _ in range(N)] print(solve(N, S, A)) def solve(N, S, A): minv = [l for l, r in A] minv.sort() half = N // 2 def fe...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import sys import operator input = sys.stdin.readline def f(med): total = 0 cnt = 0 cnt2 = 0 other = [] for x in salaries: if x[0] > med: total += x[0] # too big pay min salary cnt += 1 elif x[1] < med: total += x[0] # useless so pay min salara...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const int N = int(2e5) + 99; const int INF = int(1e9) + 100; int t; int n; long long s; pair<int, int> p[N]; bool ok(int mid) { long long sum = 0; int cnt = 0; vector<int> v; for (int i = 0; i < n; ++i) { if (p[i].second < mid) sum += p[i].first; else ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
# for #!/usr/bin/env python import os import sys from io import BytesIO, IOBase def main(): for t in range(int(input())): n,m = [int(j) for j in input().split()] ls = [] r_max = 0 # l_min = 1e9+11 for i in range(n): l,r = [int(j) for j in input().split()] m -= l r_max = max(r_max, r) # l_max = ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int>> v; int t, n; long long s; bool ok(int x) { vector<pair<int, int>> b, c; int cnt = 0; long long aux = 0; for (const auto& [l, r] : v) if (r < x) cnt++, aux += l; else if (x < l) aux += l; else c.emplace_back(l, r);...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 100; const int N = 2e5 + 100; pair<int, int> vec[N]; int n; long long s; bool check(int mid) { vector<int> temp; long long sum = 0; int cnt = 0; for (int i = 0; i < n; ++i) { if (vec[i].second < mid) { sum += vec[i].first; } else ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, maxn = 2e5 + 10; int n, m; long long s; struct node { int l, r; bool operator<(const node &x) const { return l < x.l; } } a[maxn]; bool ok(int x) { long long sum = 0; for (int i = 0; i < n; ++i) sum += a[i].l; int c = 0; for (int i = n - ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.*; import java.util.*; public class D { Random random = new Random(751454315315L + System.currentTimeMillis()); class Worker implements Comparable<Worker> { int l; int r; public Worker(int l, int r) { this.l = l; this.r = r; } @...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import sys range = xrange input = raw_input inp = sys.stdin.read().split(); ii = 0 ans = [] t = int(inp[ii]); ii += 1 for _ in range(t): n = int(inp[ii]); ii += 1 s = int(inp[ii]); ii += 1 L = [int(x) for x in inp[ii :ii + 2 * n: 2]] R = [int(x) for x in inp[ii + 1:ii + 2 * n: 2]] ii += 2 * n ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const long INF = 1000 * 1000 * 1000; const long long int mod = 1000000007; long long int l[300000], r[300000]; int main() { std::ios::sync_with_stdio(false); int t; cin >> t; while (t--) { int n, c; cin >> n; long long int s, sum = 0; cin >> s; f...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.util.*; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.math.BigInteger; import java.util.Scanner; import...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; void solve() { int n; long long int k; cin >> n >> k; vector<pair<int, int> > a(n); for (int i = 0; i < n; i++) { cin >> a[i].first >> a[i].second; } sort(a.begin(), a.end()); int ans = -1; long long int l = 0, r = 2e9; for (int i = 0; i < 60; i++) {...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int N; int l[maxn], r[maxn]; long long s; int check(int x) { int must_g = 0, must_s = 0; long long sum = 0; vector<int> num; for (int i = 1; i <= N; i++) { if (r[i] < x) must_s++, sum += l[i]; else if (l[i] > x) must_g++...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
// @uthor -: puneet // TimeStamp -: 11:27 PM - 31/10/19 import java.io.*; import java.math.BigInteger; import java.util.*; public class Bserach implements Runnable { public void solve() { int t=in.ni(); while (t-->0){ ArrayList<Pair> list=new ArrayList<>(); int n=in.ni(); ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.*; import java.util.*; public class Q3 { static int bs(long arr[][], long sum, long mid) { int cntBig = 0, cntSmall = 0, n = arr.length; for (int i = 0; i < n; i++) { if (arr[i][1] < mid) { cntSmall++; sum -= arr[i][0]; } else...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
# -*- coding: utf-8 -*- # @Time : 2021/2/4 7:21 δΈ‹εˆ # @Author : qu # @Email : quzhenqing@zju.edu.cn # @File : D. Salary Changing.py from sys import stdin t = int(stdin.readline()) for _ in range(t): n, s = map(int, stdin.readline().split()) lr = [list(map(int, stdin.readline().split())) for i in range(...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const int N = 1e6; int n, vis[N + 2]; long long s; vector<pair<int, int> > v; bool ok(int md) { for (int i = 0; i < n; i++) vis[i] = 0; int cnt = (n + 1) / 2; long long ss = s; for (int i = n - 1; i >= 0; i--) { if (v[i].second >= md && cnt) vis[i] = 1, cnt--, s...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimization("Ofast") #pragma GCC optimization("unroll-loops") #pragma GCC target("avx2,avx,fma") int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int i, j, t; cin >> t; for (i = 0; i < t; i++) { int n; long l...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.BufferedWriter; import java.io.DataInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); for(int ie=0;ie<t;ie++) { int n=s.nextInt(); long to=s.nextLong(); pair[] arr=new pair[n]; for(int...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 69; const int64_t INF = 100000000000000018LL; long long p[N], n, szz[N], m, k; long long check(vector<pair<long long, long long> >& v, long long m, long long s) { long long i, l_b = (long long)v.size() / 2, r_b = 1 + (long long)v.size()...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import sys input = sys.stdin.readline t=int(input()) while t>0: t-=1 n,ss=map(int,input().split()) lr=[] sl=0 for i in range(n): l,r=map(int,input().split()) sl+=l lr.append([l,r]) l=0 r=10**9+1 while r-l>1: mid=(r+l)//2 s=[] for i...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); Task solver = new Task(); int t = scan.nextInt(); while (t --> 0) solver.solve(1, scan,...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; struct Data { long long l, r; } a[200100]; long long n, s, rmax, lmin; void Docfile() { scanf("%lld%lld", &n, &s); rmax = 0; lmin = 1e18; for (int i = 1; i <= n; i++) { scanf("%lld%lld", &a[i].l, &a[i].r); rmax = max(rmax, a[i].r); lmin = min(lmin, a[i...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.*; import java.util.*; public class codeforces { public static PrintWriter out; public static class MyScanner { BufferedReader br; StringTokenizer st; public MyScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreEleme...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> long long n, s; std::vector<std::pair<long long, long long>> employees(200000, std::make_pair(-1, -1)); bool baz(long long mid) { long long g_cnt = 0; std::vector<long long> limbo; long long sal = 0; for (long long i = 0; i < n; ++i...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class SalaryChanging { public static void main(String[] args) throws IOException { Buffered...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Comparator; import java.util.PriorityQueue; public class d { static BufferedReader s = new BufferedReader(new InputStreamReader(System.in)); // static Scanner s=new Scanner(System.in); public static...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.util.Arrays; import java.util.Scanner; public class que4 { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int test = scn.nextInt(); for (int t = 1; t <= test; t++) { int n = scn.nextInt(); long s = scn.nextLong(); long[] low = new long[n]; long[] rit = n...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
//package codeforces.contests.eduround75; import java.io.*; import java.util.*; /** * @author tainic on Oct 24, 2019 */ public class D { private static boolean LOCAL; static { try { LOCAL = "aurel".equalsIgnoreCase(System.getenv().get("USER")); } catch (Exception e){} } private static fina...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.util.*; import java.io.*; import java.math.BigInteger; public class Main { static final int mod = (int)1e9+7; static int N = (int)2e6 + 2; static long[][] salary; public static void main(String[] args) throws Exception { FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.o...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { FastReader scan = new FastReader(); PrintWriter out = new PrintWriter(System.out); Task solver = new Task(); int t = scan.nextInt(); while (t --> 0) solver.solve(1, scan, out)...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const long long MOD = (long long)(1e9 + 7); const long long N = 200007; vector<pair<long long, long long>> v; long long s; int n; int sure(long long median) { long long cnt1 = 0; long long cnt2 = 0; long long cnt3 = 0; long long sum = 0; vector<long long> tmp; f...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.math.BigInteger; import java.util.*; public class SalaryChanging_task2 { static int INF = (int) (1E9 + 100); public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int test = scanner.nextInt(); for (int i = 0; i < test; i++) { int n ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; int t, n; long long s, sum; pair<int, int> opt[maxn]; bool check(int mid) { int k = 0; long long total = sum; for (int i = n; i >= 1; --i) { if (opt[i].second >= mid) { k++; if (mid >= opt[i].first) total += mid - opt[i].firs...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long>> a; long long s, n; bool check(long long mid) { long long cnt = 0; vector<long long> b; long long sum = 0; for (long long i = 0; i < n; i++) { if (a[i].second < mid) sum += a[i].first; else if (a[i].first >= mid) { ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; struct node { long long l, r; } a[200010]; long long n, s; inline long long v_in() { char ch = getchar(); long long sum = 0, f = 1; while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) sum = (sum << 3) + (sum << 1) + (ch ^ ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** If I'm the sun, you're the moon Because when I go up, you go down ******************************* I'm working for the day I will surpass you https://www.a2oj.com/Ladder16.html */ impor...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int T; cin >> T; while (T--) { int N; long long S; cin >> N >> S; long long R[N]; pair<long long, long long> LR[N]; for (int i = 0; i < N; ++i) { long long l, r; cin >...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; long long n, s, l[200005]; pair<long long, long long> arr[200005]; bool valid(long long x) { long long cnt = 0; long long sum = 0, z; vector<long long> v; for (int i = 1; i <= n; i++) { if (arr[i].second < x) { sum += arr[i].first; } else if (arr[i].fi...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> int II() { int n; scanf("%d", &n); return n; } long long int LL() { long long int n; scanf("%lld", &n); return n; } void IIn(int n) { printf("%d\n", n); } char* SS(char* str) { scanf("%s", str); return str + strlen(str); }; void SSn(char* str) { printf("%s\n", str); } constexpr ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; /** * Created by himanshubhardwaj on 24/10/19. */ public class SalaryChanging { public static void main(S...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
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...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import sys input = lambda: sys.stdin.readline().rstrip() T = int(input()) for _ in range(T): N, S = map(int, input().split()) X = [] for __ in range(N): l, r = map(int, input().split()) X.append((l, r)) ok = 1 ng = 10**9+1 while ng - ok > 1: m = (ok+ng) // 2 ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> template <typename T> T GCD(T a, T b) { return a ? GCD(b % a, a) : b; } template <typename T> T LCM(T a, T b) { return (a * b) / GCD(a, b); } template <typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) { for (auto ob : v) os << ob << " "; return os; } templ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; long long int max(long long int a, long long int b) { if (a > b) return a; else return b; } long long int min(long long int a, long long int b) { if (a < b) return a; else return b; } const int dx[4] = {-1, 1, 0, 0}; const int dy[4] = {0, 0, -1, 1}; ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
# ---------------------------iye ha aam zindegi--------------------------------------------- import math import heapq, bisect import sys from collections import deque, defaultdict from fractions import Fraction import sys mod = 10 ** 9 + 7 mod1 = 998244353 # ------------------------------warmup------------------------...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; void itval(istream_iterator<string> it) {} template <typename T, typename... Args> void itval(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; itval(++it, args...); } const long long int MOD = 1e9 + 7; template <typename T> inline voi...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const long long MAXN = 2e5 + 5; pair<long long, long long> a[MAXN]; long long s; long long n; bool check(long long x) { long long sum = 0, cnt = 0; vector<long long> nums; for (long long i = 0; i < n; i++) { if (a[i].first >= x) { sum += a[i].first; cn...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.util.*; import java.io.*; public class SalChange { static BufferedReader br; static StringTokenizer tokenizer; public static void main(String[] args) throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); int t = nextInt(); for(int x = 0; x < t; x++) { int n = nextInt();...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOExcept...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; int n; long long s; vector<pair<long long, long long>> v; bool feasible(long long mid) { long long sum = 0; int cnt = 0, need; vector<long long> ans; for (int i = 0; i < v.size(); i++) { if (v[i].second < mid) sum += v[i].first; else if (v[i].first > m...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.*; import java.util.*; //import javafx.util.*; import java.math.*; //import java.lang.*; public class Main { // static int n;static ArrayList<Integer> adj[]; // static int m; // static boolean v[]; // static int a[]; // static int leaf[]; // static int dist[]; // ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; int t, n; long long s; struct node { long long l, r; } nod[200005]; vector<long long> ve; int main() { scanf("%d", &t); while (t--) { scanf("%d%lld", &n, &s); for (int i = 1; i <= n; ++i) scanf("%lld%lld", &nod[i].l, &nod[i].r); long long l = 1, r = s, mid...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
def check(mid): x=[] y=[] z=[] for i in it: if i[1]<mid: x.append(i) elif i[0]>=mid: y.append(i) else: z.append(i) co=sum([i[0] for i in x]) co+=sum([i[0] for i in y]) ll=len(y) m=0 #if len(z)==0: # return False n...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; int l[200005], r[200005]; pair<int, int> p[200005]; int main() { int q; scanf("%d", &q); while (q--) { int n; long long s; scanf("%d%lld", &n, &s); for (int i = 1; i <= n; i++) { scanf("%d%d", &l[i], &r[i]); p[i] = pair<int, int>(l[i], r[i]...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.util.*; public class Solution { static boolean check(int x , pair[] arr,long s) { int cnt = 0; long req = 0; for(int i = arr.length-1 ; i >= 0 ; i--) { if(x <= arr[i].r && cnt != arr.length/2+1) {...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.util.*; import java.lang.*; import java.io.*; public class Solution { public static void main (String[] args) throws java.lang.Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); int t= Integer.parseInt(br.readLine()...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
// created by Whiplash99 import java.io.*; import java.util.*; public class D { static class Employee { long l,r; Employee(long l, long r) { this.l=l; this.r=r; } } public static void main(String[] args) throws IOException { BufferedRea...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long>> v; long long n, s; bool ok(int mid) { long long sum = 0; long long cnt = 0; vector<long long> vec; for (int i = 0; i < n; i++) { if (v[i].second < mid) sum += v[i].first; else if (v[i].first >= mid) { sum += v[i...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import os import sys from io import BytesIO, IOBase # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.wr...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
// Working program using Reader Class import java.io.*; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; public class NumberInput { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataIn...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf1251d { public static void main(String[] args) throws IOException { int t = ri(); while (t --> 0) { int n = rni(); long s = nl(); int l[] = ne...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { for (ll i = 0; i < v.size(); ++...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.PriorityQueue; import java.util.AbstractQueue; import java.io.IOException; import java.io.UncheckedIOException; import java.util.AbstractCollection; import java.io.Closeable; import java.io...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const long long mod = 1e9 + 7; void chmod(lo...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const long long INF = mod * mod; int n; long long s; pair<long long, long long> p[200010]; bool check(long long mid) { sort(p, p + n, [&mid](const pair<long long, long long> &a, const pair<long long, long long> &b) { ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import sys input = sys.stdin.readline def check(num): count1=0 count2=0 spent=0 left=[] for i in l: if i[0]>num: count2+=1 spent+=i[0] elif i[1]<num: count1+=1 spent+=i[0] else: left.append(i) # if num==36: # print (num,left,spent,count2,count1) if count2>n//2+1: return True elif count...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; int n; long long s; vector<array<int, 2>> v(200001); bool check(int x) { int cnt = n / 2 + 1; long long res = 0; for (int i = n - 1; i > -1 && res <= s; i--) { if (cnt && v[i][1] >= x) { res += max(x, v[i][0]); cnt--; } else res += v[i][0]; ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; struct IOSetup { IOSetup() { cin.tie(nullptr); ios_base::sync_with_stdio(false); ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; bool possible(long long val, long long s, vector<pair<int, int>> &pl, int n) { long long tot = 0, cnt = (n + 1) / 2; vector<int> llp; for (int i = 0; i < n; i++) { if (pl[i].first >= val) { tot += pl[i].first; cnt--; ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const long double pi = 3.14159265358979323; long long mod = 1000000000 + 7; long long modu = 998244353; const long double pii = acos(-1.0); const long long INF = 1e18; const long long inf = 1e9; long long power(long long x, long long y) { long long res = 1; x = x; whi...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const long long int N = 5e5 + 5, mod = 1000000007, bit = 60; bool comp(pair<long long int, long long int> &a, pair<long long int, long long int> &b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; } bool comp1(pair<l...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
a=int(input()) ans=[] import sys input=sys.stdin.readline def checker(ans,mid,n,s): g1=n//2 c1=0 c2=0 c3=0 cost=0 t1=[] for i in range(len(ans)): if(ans[i][0]<=mid<=ans[i][1]): t1.append([ans[i][0],ans[i][1]]) elif(ans[i][1]<mid): c3...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const long long md = 1e9 + 7; const long long MX = 2e5 + 5; const long long INF = 1e18; const long double PI = 4 * atan((long double)1); long long power_md(long long a, long long n) { long long res = 1; while (n) { if (n % 2) res = (res % md * a % md) % md; a = ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.*; import java.util.*; public class Main { static InputReader in = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); static int oo = (int)1e9; static int mod = 1_000_000_007; static int[] di = {1, 0, 0, -1}; static int[] dj = {0, -1, 1, 0}; static int ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; long long s; int n; vector<pair<int, int>> lims; int solve(int median) { int smallcnt = 0; int largecnt = 0; long long rem = s; for (int i = 0; i < n; i++) if (lims[i].second < median) { smallcnt++; rem -= lims[i].first; } else if (lims[i].first ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
def check(x, s, a, n): num = (n+1) // 2 cur = 0 sum_ = 0 for i in range(n-1, -1, -1): l, r = a[i] if cur == num: break if l >= x: cur += 1 elif l <= x and x <= r: cur += 1 sum_ +...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> const int INF = 1e9 + 7; const int MAXN = 3e5 + 20; const double eps = 1e-9; const long long inf = 1e18; const long double pi = acos(-1.0); using namespace std; int n; long long s; long long a[MAXN], b[MAXN]; long long cnt1, cnt2, pr, l, r, ans, m; long long sum; void solve() { cin >> n >> s;...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const int maxn = 3 * 1e5 + 10; struct node { long long l, r; } a[maxn]; int n; long long m; bool cmp(node a, node b) { if (a.l != b.l) return a.l > b.l; return a.r > b.r; } bool f(long long x) { int num = 0; long long sum = 0; for (int i = 0; i < n; i++) { i...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 5; long long tot; int n; pair<int, int> a[maxn]; bool judge(int mid) { long long sum = 0; int cnt = 0; vector<int> v; for (int i = 0; i < n; i++) { if (a[i].second < mid) sum += a[i].first; else if (a[i].first >= mid) { sum...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.util.*; import java.io.*; import java.text.*; public class Main{ //SOLUTION BEGIN //Into the Hardware Mode void pre() throws Exception{} void solve(int TC)throws Exception{ int n = ni(); long s = nl(); Person[] a = new Person[n]; for(int i = 0; i< n; i++){ ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; struct node { long long int l, r; } inp[200010]; long long n, s; bool cmp(node a, node b) { return a.l > b.l; } bool check(long long int m) { long long int sum = 0; int cnt = 0; for (int i = 0; i < n; i++) { sum += inp[i].l; } for (int i = 0; i < n; i++) { ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
#include <bits/stdc++.h> using namespace std; int q, n; long long s; class emp { public: long long l, r; emp() {} emp(long long l, long long r) : l(l), r(r) {} bool operator<(const emp& other) const { if (l != other.l) return l < other.l; return r < other.r; } }; emp E[200010]; bool f(long long med) ...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import sys import operator input = sys.stdin.buffer.readline def f(med): total = 0 cnt = 0 for x in salaries: # print(x) if x[1] < med: total += x[0] # useless so pay min salaray else: if cnt < n/2: total += max(x[0],med) cnt...
You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from l_i to r_i dollars. You have to distribute salaries in such a way that the ...
import java.io.*; import java.util.*; public class Main { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); long sum=sc.nextLong(); Pair a[]=new Pair[n]; for( int i=0;i<n;i++) { a[i]=new P...