output
stringlengths
52
181k
instruction
stringlengths
296
182k
#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 ...
### Prompt In Cpp, your task is to solve the following problem: 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_...
#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);...
### Prompt Please provide a Cpp coded solution to the problem described below: 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...
#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 ...
### Prompt Create a solution in cpp for the following problem: 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...
#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 - ...
### Prompt Your challenge is to write a Cpp solution to the following problem: 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...
#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...
### Prompt Develop a solution in CPP to the problem described below: 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 ...
#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++) {...
### Prompt Please create a solution in cpp to the following problem: 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 ...
#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++...
### Prompt In Cpp, your task is to solve the following problem: 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_...
#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...
### Prompt Construct a Cpp code solution to the problem outlined: 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 ...
#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...
### Prompt Create a solution in Cpp for the following problem: 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...
#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()...
### Prompt Your task is to create a Cpp solution to the following problem: 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 fro...
#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...
### Prompt Your challenge is to write a Cpp solution to the following problem: 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...
#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...
### Prompt Your task is to create a cpp solution to the following problem: 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 fro...
#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...
### Prompt In CPP, your task is to solve the following problem: 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_...
#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...
### Prompt Please formulate a Cpp solution to the following problem: 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 ...
#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) { ...
### Prompt Your task is to create a CPP solution to the following problem: 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 fro...
#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 ^ ...
### Prompt Your task is to create a cpp solution to the following problem: 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 fro...
#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 >...
### Prompt Please formulate a CPP solution to the following problem: 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 ...
#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...
### Prompt Your challenge is to write a cpp solution to the following problem: 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...
#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 ...
### Prompt In cpp, your task is to solve the following problem: 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_...
#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...
### Prompt In CPP, your task is to solve the following problem: 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_...
#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}; ...
### Prompt Develop a solution in Cpp to the problem described below: 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 ...
#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...
### Prompt In cpp, your task is to solve the following problem: 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_...
#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...
### Prompt Please formulate a cpp solution to the following problem: 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 ...
#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...
### Prompt In cpp, your task is to solve the following problem: 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_...
#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...
### Prompt Develop a solution in Cpp to the problem described below: 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 ...
#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]...
### Prompt Construct a Cpp code solution to the problem outlined: 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 ...
#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...
### Prompt Generate a cpp solution to the following problem: 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 d...
#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(); ++...
### Prompt Develop a solution in CPP to the problem described below: 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 ...
#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...
### Prompt Please formulate a cpp solution to the following problem: 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 ...
#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) { ...
### Prompt Generate a cpp solution to the following problem: 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 d...
#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]; ...
### Prompt Develop a solution in cpp to the problem described below: 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 ...
#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); ...
### Prompt Create a solution in Cpp for the following problem: 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...
#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--; ...
### Prompt Please provide a CPP coded solution to the problem described below: 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...
#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...
### Prompt Generate a cpp solution to the following problem: 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 d...
#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...
### Prompt In CPP, your task is to solve the following problem: 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_...
#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 = ...
### Prompt Generate a cpp solution to the following problem: 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 d...
#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 ...
### Prompt In Cpp, your task is to solve the following problem: 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_...
#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;...
### Prompt Please formulate a Cpp solution to the following problem: 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 ...
#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...
### Prompt Please provide a cpp coded solution to the problem described below: 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...
#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...
### Prompt Please formulate a cpp solution to the following problem: 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 ...
#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++) { ...
### Prompt Develop a solution in Cpp to the problem described below: 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 ...
#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) ...
### Prompt Please create a solution in Cpp to the following problem: 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 ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; struct node { int l; int r; } a[N]; bool cmp(node a, node b) { if (a.l == b.l) return a.r > b.r; return a.l > b.l; } long long n, s; int check(int x) { int k = n / 2, cnt = 0; long long sum = 0; for (int i = 0; i < n; i++) { if (a[i...
### Prompt Please formulate a cpp solution to the following problem: 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 ...
#include <bits/stdc++.h> using namespace std; long long t, n, S, s, up, down, mid, mx, mn, a, b, k, l, r, ans, raod; pair<long long, long long> p[300005]; int main() { cin >> t; while (t--) { cin >> n >> S; mn = 1e10; mx = 0; for (k = 1; k <= n; k++) { cin >> a >> b; p[k].first = a; ...
### Prompt Please formulate a cpp solution to the following problem: 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 ...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > v; bool check(long long mid, int cnt, long long total) { int i, c = 0, c1 = 0; long long sum = 0; vector<long long> tmp; for (i = 0; i < v.size(); i++) { if (v[i].second < mid) sum += v[i].first; else if (mid < v[i].first) { ...
### Prompt Please create a solution in Cpp to the following problem: 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 ...
#include <bits/stdc++.h> using namespace std; int takemod(int a, int mod) { a %= mod; if (a < 0) a += mod; return a; } int fast_exp(int base, int expo, int mod) { int res = 1; while (expo > 0) { if (expo & 1) res = (res * base) % mod; base = (base * base) % mod; expo >>= 1; } return res; } int...
### Prompt In cpp, your task is to solve the following problem: 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_...
#include <bits/stdc++.h> using namespace std; pair<long long, long long> ara[200005]; int n; long long s; bool cheak(long long m) { long long rem = s; for (int i = 0; i < n; i++) rem -= ara[i].first; int p = (n + 1) >> 1; for (int i = 0; i < n && p; i++) { if (ara[i].first >= m) p--; else if (ara[...
### Prompt Your challenge is to write a CPP solution to the following problem: 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...
#include <bits/stdc++.h> using namespace std; const int INF = 1001001001; const long long LINF = 1e17; const double pi = 3.1415926535897932; const string endstr = "\n"; template <typename T> T gcd(T a, T b) { return (a == 0) ? b : gcd(b % a, a); } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } ...
### Prompt Generate a CPP solution to the following problem: 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 d...
#include <bits/stdc++.h> using namespace std; long long int a[200010][2]; bool check(long long int m, long long int n, long long int s) { long long int aa = 0, bb = 0; long long int sal = 0; vector<pair<int, int>> v; for (int i = 0; i < n; i++) { if (a[i][1] < m) aa++, sal = sal + a[i][0]; else if...
### Prompt Your challenge is to write a cpp solution to the following problem: 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...
#include <bits/stdc++.h> using namespace std; const int maxn = 233333; long long suml = 0, n, s; struct node { int l, r; } e[maxn]; bool cmp(node a, node b) { if (a.l == b.l) return a.r < b.r; return a.l < b.l; } int vis[maxn]; bool check(int x) { long long now = suml; int cnt = 0; for (int i = n; i >= 1; i...
### Prompt Create a solution in CPP for the following problem: 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...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 5; struct Node { int L, R; bool operator<(const Node &other) const { return L < other.L; } }; int N, H; long long S; vector<Node> v; bool possible(int median) { long long sum = 0; for (Node &s : v) sum += s.L; int count = 0; for (int i = N ...
### Prompt Develop a solution in CPP to the problem described below: 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 ...
#include <bits/stdc++.h> using namespace std; int N, N2; long long S; const int MAXN = 2e5 + 15; pair<long long, long long> A[MAXN]; long long I[MAXN]; bool check(long long m) { int c2 = 0, n = 0; long long sum = 0; for (int i = 0; i < N; ++i) if (A[i].second < m) { sum += A[i].first; } else if (A[i...
### Prompt Generate a cpp solution to the following problem: 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 d...
#include <bits/stdc++.h> using namespace std; int main() { int q; scanf("%d", &q); while (q--) { int n; long long s; scanf("%d %I64d", &n, &s); long long deb = 0, fin = s; int l[n], r[n]; for (int i = 0; i < n; i++) { scanf("%d %d", &l[i], &r[i]); s -= l[i]; } while (de...
### Prompt Your task is to create a CPP solution to the following problem: 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 fro...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 200ll; bool can(vector<pair<int, int>> a, long long tar, int n, long long s) { int cnt = 0; long long sum = 0ll; vector<int> use; for (int i = 0; i < n; ++i) { if (a[i].second < tar) { sum += (long long)a[i].first; } else if...
### Prompt Your challenge is to write a cpp solution to the following problem: 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...
#include <bits/stdc++.h> using namespace std; pair<long long, long long> a[200010]; long long n, s; bool ok(long long x) { long long cnt = 0, left = s; for (long long i = 0; i < n; i++) left -= a[i].first; for (long long i = 0; i < n; i++) { if (a[i].first >= x) cnt++; else if (a[i].second >= x) { ...
### Prompt Please provide a CPP coded solution to the problem described below: 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...
#include <bits/stdc++.h> using namespace std; long long n, s; vector<pair<long long, long long> > arr; bool can(long long x) { long long ans = 0; vector<pair<long long, long long> > todo; for (long long i = 0; i < n; i++) { if (arr[i].second < x) todo.push_back(arr[i]); } for (long long i = 0; i < n; i++)...
### Prompt Construct a Cpp code solution to the problem outlined: 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 ...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int N = 2e5 + 10; int n; long long s; struct node { int l, r; bool operator<(const node& a) const { return l < a.l; } } p[N]; vector<int> g; int judge(long long x) { g.clear(); long long sum = 0, cnt1 = 0, cnt2 = 0; for (int i = 1...
### Prompt In CPP, your task is to solve the following problem: 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_...
#include <bits/stdc++.h> using namespace std; struct node { int l, r; friend bool operator<(node a, node b) { return a.l < b.l; } } ee[200005]; int get(int n, int x, long long k) { long long sum = 0; int cnt = n / 2 + 1; for (int i = n; i >= 1; i--) { if (ee[i].l <= x && ee[i].r >= x && cnt) { sum +...
### Prompt Generate a Cpp solution to the following problem: 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 d...
#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...
### Prompt Your task is to create a cpp solution to the following problem: 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 fro...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { ll n, s; cin >> n >> s; vector<array<int, 2>> ranges(n); for (int i = 0; i < n; i++) { cin >> ranges[i][0] >> ranges[i][1]; } ...
### Prompt Construct a Cpp code solution to the problem outlined: 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 ...
#include <bits/stdc++.h> using namespace std; const int64_t MOD = 1000000007; int64_t l[200001]; int64_t r[200001]; int64_t get(int64_t x, int64_t s, int64_t n) { vector<int64_t> arr; int64_t a = 0, b = 0; for (int64_t i = 1; i <= n; i++) { if (r[i] < x) s -= l[i], a++; else if (l[i] >= x) s -...
### Prompt Please create a solution in cpp to the following problem: 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 ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; const long long inf = 1e14 + 5; inline long long min(long long a, long long b) { return a < b ? a : b; } struct Node { int l, r; } a[MAXN]; inline bool cmp_l(const Node &p, const Node &q) { return p.l < q.l; } int n; long long s; bool chk(int mid...
### Prompt Construct a Cpp code solution to the problem outlined: 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 ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; bool prime[1000001]; long long spf[10000001]; long long f[300005]; long long pow1(long long x, long long y) { long long res = 1; x = x % mod; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % mod; y = y >> 1; ...
### Prompt Please provide a CPP coded solution to the problem described below: 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...
#include <bits/stdc++.h> using namespace std; bool isok(vector<pair<long long, long long> > &A, long long mid, long long s) { long long sum = 0, c = 0, left = 0, n = A.size(); vector<char> visited(n, 0); for (long long i = 0; i < (n); i++) { if (A[i].second < mid) { c++; sum += A[i].first; v...
### Prompt Construct a Cpp code solution to the problem outlined: 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 ...
#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) { ...
### Prompt Please provide a Cpp coded solution to the problem described below: 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...
#include <bits/stdc++.h> using namespace std; long long n, s, curs; const long long maxn = 2e5 + 10; pair<long long, long long> vec[maxn]; long long v[maxn]; bool check(long long mid) { if (mid == s + 1) return false; long long sz = 0; for (long long i = 0; i < n; i++) { if (vec[i].second >= mid) v[sz++] = ve...
### Prompt In Cpp, your task is to solve the following problem: 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_...
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n, k; cin >> n >> k; vector<pair<int, int> > v; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; v.push_back({a, b}); } sort(v.begin(), v.end()); long long ...
### Prompt Please formulate a Cpp solution to the following problem: 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 ...
#include <bits/stdc++.h> using namespace std; long long l[300100], r[300100]; long long n, sal; signed main() { long long t; scanf("%lld", &t); while (t--) { scanf("%lld %lld", &n, &sal); for (long long i = 1; i <= n; i++) scanf("%lld %lld", &l[i], &r[i]); long long bg = 1, nd = 1e9; while (bg < n...
### Prompt Your challenge is to write a CPP solution to the following problem: 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...
#include <bits/stdc++.h> using namespace std; long long n; struct node { long long l, r; } a1[200005], a2[200005], e[200005]; inline long long read() { long long x = 0, f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0...
### Prompt Your task is to create a cpp solution to the following problem: 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 fro...
#include <bits/stdc++.h> using namespace std; struct node { int l, r; } a[200009]; int n; long long k; bool cmp(node aa, node bb) { if (aa.l == bb.l) return aa.r < bb.r; else return aa.l < bb.l; } int check(int x) { long long ans = 0; int w = 0; for (int i = n; i >= 1; i--) { if (w <= n / 2) { ...
### Prompt Develop a solution in Cpp to the problem described below: 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 ...
#include <bits/stdc++.h> const double PI = 3.141592653589793238460; using namespace std; pair<long long int, long long int> ar[200001]; bool isPossible(long long int mid, long long int s, long long int n) { long long int sum = 0; int cnt = 0; vector<int> va, vb, vc; for (int i = 1; i <= n; i++) { if (ar[i]....
### Prompt Create a solution in Cpp for the following problem: 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...
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 7; const long long INF = 1e9; const long long MOD = INF + 7; long long n, s; vector<pair<long long, long long> > a; bool solve(long long m) { long long idx = (long long)n / 2; long long sm = 0; for (long long i = 0; i < n; i++) { sm += a[...
### Prompt Develop a solution in Cpp to the problem described below: 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 ...
#include <bits/stdc++.h> using namespace std; int dirx[] = {1, -1, 0, 0}, diry[] = {0, 0, 1, -1}; long long bigmod(long long x, long long p) { long long res = 1; while (p) { if (p & 1) res = (res * x) % 998244353; x = (x * x) % 998244353; p >>= 1; } return res; } vector<pair<int, int> > inp; int n; ...
### Prompt Create a solution in CPP for the following problem: 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...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int t, n; long long s; struct uzi { int l, r; bool operator<(const uzi& t) const { return l > t.l; } } p[N]; int vis[N]; int main() { ios::sync_with_stdio(false); for (cin >> t; t; t--) { cin >> n >> s; long long S = 0; for (int i...
### Prompt Generate a CPP solution to the following problem: 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 d...
#include <bits/stdc++.h> using namespace std; std::mt19937 rng( (int)std::chrono::steady_clock::now().time_since_epoch().count()); const double EPS = 1e-9; const double PI = acos(-1); const int MOD = 1000000007; vector<pair<long long, long long> > v; int n; long long s; bool test(long long x) { long long sum = 0;...
### Prompt Generate a CPP solution to the following problem: 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 d...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; long long s, sum; int T, n; pair<int, int> L[N]; bool judge(long long val) { long long v = s; int num = (n + 1) / 2; for (int i = 1; i <= n; i++) { v -= L[i].first; if (L[i].first >= val) num--; } vector<int> cost; for (int i = 1;...
### Prompt Your task is to create a cpp solution to the following problem: 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 fro...
#include <bits/stdc++.h> using namespace std; bool isValid(const long long& median, const vector<pair<long long, long long>>& ranges, const long long& s) { long long select_count = 0; long long sum = 0; for (int i = 0; i < ranges.size(); i++) { if (select_count < (ranges.size() + 1) ...
### Prompt Create a solution in CPP for the following problem: 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...
#include <bits/stdc++.h> using namespace std; template <class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; } long long POW(long long a, long long p, long long M) { if (!p) return 1LL; long long T = POW(a, p / 2,...
### Prompt Your challenge is to write a Cpp solution to the following problem: 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...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; const int INF = 0x3f3f3f3f, N = 1000005, M = 2000005, MOD = 2017; int sgn(double x) { return x < -eps ? -1 : (x < eps ? 0 : 1); } int Rand(int x) { return rand() * rand() % x + 1; } struct node { int l, r; bool operator<(const node &x) const { ...
### Prompt Your challenge is to write a CPP solution to the following problem: 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...
#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...
### Prompt Please create a solution in CPP to the following problem: 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 ...
#include <bits/stdc++.h> using pp = std::pair<int, int>; int main() { std::ios::sync_with_stdio(false); int t = 0; std::cin >> t; for (int k = 0; k < t; ++k) { int n = 0; long long s = 0, sum = 0; std::cin >> n >> s; pp p[n]; for (int i = 0; i < n; ++i) { std::cin >> p[i].first >> p[i]...
### Prompt Construct a Cpp code solution to the problem outlined: 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 ...
#include <bits/stdc++.h> using namespace std; const long double PI = 2 * acos(0.0); void yes() { cout << "YES\n"; } void no() { cout << "NO\n"; cout << -1 << "\n"; exit(0); } long long m(long long a) { return (a + 1000000007) % 1000000007; } long long cel(long long x1, long long y1) { ; if ((x1 % y1) == 0) re...
### Prompt Your challenge is to write a Cpp solution to the following problem: 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...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; long long t, n, m; struct p { long long l, r; bool operator<(const p& tmp) const { return l < tmp.l; } } a[maxn]; bool col(p a, p b) { return a.l < b.l; } bool cor(p a, p b) { return a.r > b.r; } bool isok(long long mid) { priority_queue<p> ...
### Prompt Please create a solution in CPP to the following problem: 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 ...
#include <bits/stdc++.h> using namespace std; const long long inf = 0x3f3f3f3f3f3f3f3f; const int mod = 1e9 + 7; const int maxn = 2e6 + 4; const int N = 5e3 + 5; const double eps = 1e-6; const double pi = acos(-1); long long qpow(long long x, long long y) { long long ans = 1; x %= mod; while (y) { if (y & 1) ...
### Prompt In CPP, your task is to solve the following problem: 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_...
#include <bits/stdc++.h> using namespace std; const long long int infinity = 9e18; pair<bool, long long int> isPossible( vector<pair<long long int, long long int> > &vp, long long int k, long long int s) { long long int n = vp.size(); vector<long long int> v, v1, v2; long long int a = 0, b = 0, c = 0; l...
### Prompt Please formulate a cpp solution to the following problem: 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 ...
#include <bits/stdc++.h> using namespace std; bool canDoAtLeast(long long m, long long s, vector<pair<long long, long long> > &E) { long long good = 0; vector<long long> P; for (auto [l, r] : E) { s -= l; if (l >= m) good++; else if (m <= r) { P.push_back(m - l); } ...
### Prompt Please provide a Cpp coded solution to the problem described below: 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...
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; using vi = vector<int>; using ll = long long; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int n; ll s; cin >> n >> s; vi l(n), r(n); for (int i = int(0); i < int(n); i++) cin...
### Prompt Please provide a CPP coded solution to the problem described below: 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...
#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...
### Prompt Please formulate a cpp solution to the following problem: 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 ...
#include <bits/stdc++.h> using namespace std; struct num { long long l, r; } a[200005]; bool cmp(num x, num y) { if (x.l == y.l) return x.r > y.r; return x.l > y.l; } long long n, s; long long check(long long m) { long long br = n / 2 + 1, sum = 0; for (int i = 0; i < n; i++) { if (a[i].l <= m && m <= a[i...
### Prompt In cpp, your task is to solve the following problem: 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_...
#include <bits/stdc++.h> using namespace std; long long n, s, INI; pair<long long, long long> a[200010]; bool op(long long meta) { long long quant = 0, disponivel = s; for (long long i = n; i >= 1; i--) { long long vez = meta - a[i].first; if (a[i].first >= meta) { quant++; continue; } i...
### Prompt In CPP, your task is to solve the following problem: 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_...
#include <bits/stdc++.h> using namespace std; const int maxn = 200020; inline long long read() { char ch = getchar(); long long x = 0, f = 0; while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return f ? -x : x; } struct seg { i...
### Prompt Please provide a CPP coded solution to the problem described below: 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...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1; const int M = 1e9 + 7; vector<pair<int, int> > seg; bool check(long long n, long long s, long long median) { long long less = 0, more = 0; long long cur = 0; vector<int> v; for (int i = 0; i < n; i++) { if (seg[i].second < median) { ...
### Prompt In CPP, your task is to solve the following problem: 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_...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-6; const int mod = 1e9 + 7; const int maxn = 2e6 + 100; const int maxm = 2e6 + 100; const int inf = 0x3f3f3f3f; const double pi = acos(-1.0); int t; pair<long long, long long> a[maxn]; long long s; int n; int vis[maxn]; bool cmp2(pair<long long, long l...
### Prompt Create a solution in cpp for the following problem: 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...
#include <bits/stdc++.h> using namespace std; int n; long long s; pair<int, int> a[200010]; bool take[200010]; bool good(int x) { int cnt = n / 2; long long tot = 0; for (int i = 1; i <= n; i++) { if (a[i].second < x) { tot += a[i].first; --cnt; take[i] = true; } else take[i] = fal...
### Prompt Generate a cpp solution to the following problem: 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 d...
#include <bits/stdc++.h> using namespace std; struct node { long long l, r; }; bool cmp(node a, node b) { if (a.l != b.l) return a.l < b.l; return a.r < b.r; } long long T, N, S; node a[200005]; bool can(long long x) { long long cnt = 0; long long money = 0; for (long long i = N; i >= 1; i--) { if (a[i]...
### Prompt Please create a solution in Cpp to the following problem: 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 ...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const double PI = acos(-1); long long mod = 1e9 + 7; struct segment { long long l, r; bool operator<(const segment& s) const { return l < s.l; } }; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t; cin ...
### Prompt Your challenge is to write a CPP solution to the following problem: 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...
#include <bits/stdc++.h> using namespace std; long long n, s, t, cnt, sum; const int maxn = 2e5 + 7; pair<long long, long long> a[maxn]; int main() { cin >> t; while (t--) { cin >> n >> s; for (int i = 1; i <= n; i++) { cin >> a[i].first >> a[i].second; } sort(a + 1, a + n + 1); long long ...
### Prompt In Cpp, your task is to solve the following problem: 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_...
#include <bits/stdc++.h> using namespace std; int const N = 200000, inf = 1e9; pair<int, int> x[N]; int n; vector<int> y; bool ok(int m, long long s) { y.clear(); for (int i = 0; i < (int)(n); ++i) { s -= x[i].first; if (m <= x[i].second) { if (m >= x[i].first) y.push_back(m - x[i].first); ...
### Prompt Develop a solution in CPP to the problem described below: 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 ...
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long>> f; long long n, s; bool can(long long mid) { long long sum = 0, cnt = 0; vector<long long> v; for (long long i = 0; i < n; i++) { if (f[i].second < mid) sum += f[i].first; else if (f[i].first >= mid) { sum += f[i]...
### Prompt Your task is to create a CPP solution to the following problem: 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 fro...
#include <bits/stdc++.h> using namespace std; struct range { int l, r, id; } rng[200010]; int vis[200010]; int n; long long s; bool find(int m) { for (int i = 1; i <= n; i++) vis[i] = 0; int lcnt(0), rcnt(0); long long sum(0); for (int i = 1; i <= n; i++) { if (rng[i].r < m) { lcnt++; sum += r...
### Prompt Please provide a Cpp coded solution to the problem described below: 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...