Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
122_E. Lucky Permutation | Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya dreamt of a lexicographically k-th permutation of integers from 1 to n. Determine how ... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
set<long long> S;
void go(const long long &x, const int &M, const long long &U) {
if (x > U) return;
if (x > M) S.insert(x);
go(10 * x + 4, M, U), go(10 * x + 7, M, U);
}
bool ok(long long x) {
for (; x; x /= 10) {
int a = x % 10;
if (a != 4 && a != 7) retur... | CPP |
122_E. Lucky Permutation | Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya dreamt of a lexicographically k-th permutation of integers from 1 to n. Determine how ... | 2 | 11 | debug = False
import sys, math
def out():
FIN.close()
FOUT.close()
sys.exit()
def num(ind):
i = 0
k = ind
while k > 0:
i += 1
if not f[i]:
k -= 1
return i
def nextlucky(x):
s = str(x)
lens = len(s)
for i in range(lens - 1, -1, -1):
if s[i... | PYTHON |
122_E. Lucky Permutation | Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya dreamt of a lexicographically k-th permutation of integers from 1 to n. Determine how ... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int inf = 1000000005;
long long int llinf = 2000000000000000005LL;
long long int mod = 1000000007;
long long int mod9 = 1000000009;
double pi = 3.1415926535897;
double eps = 1e-15;
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1}, dy[] = {0, 0, 1, -1, 1, 1, -1, -1};
vector<bool> ispr... | CPP |
122_E. Lucky Permutation | Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya dreamt of a lexicographically k-th permutation of integers from 1 to n. Determine how ... | 2 | 11 | import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Collection;
import java.io.InputStream;
import java.util.Vector;
/**
* Built using CHelper plug-in
* Actual sol... | JAVA |
122_E. Lucky Permutation | Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya dreamt of a lexicographically k-th permutation of integers from 1 to n. Determine how ... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int N, K;
vector<int> lucky;
void gen(long long N, long long v) {
if (v > N) {
return;
}
if (v != 0) {
lucky.push_back((int)v);
}
gen(N, 10 * v + 4);
gen(N, 10 * v + 7);
}
vector<int> fact;
vector<int> a;
set<int> s;
void gen2(int K, int index) {
if (i... | CPP |
122_E. Lucky Permutation | Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya dreamt of a lexicographically k-th permutation of integers from 1 to n. Determine how ... | 2 | 11 | #include <bits/stdc++.h>
int mul[14];
int Lucky[1025], tot;
void pre() {
mul[0] = 1;
for (int i = 1; i < 14; i++) mul[i] = mul[i - 1] * i;
for (int bit = 1; bit < 10; bit++) {
for (int i = 0; i < 1 << bit; i++) {
int num = 0;
for (int j = bit - 1; j >= 0; j--) {
if (i >> j & 1)
n... | CPP |
122_E. Lucky Permutation | Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya dreamt of a lexicographically k-th permutation of integers from 1 to n. Determine how ... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, k, c;
long long factN = 1;
int a[20], tk[20];
int lck[100000], reach = 0;
void DFS(long long x) {
if (x > 1000000000) {
return;
}
lck[reach++] = x;
DFS(x * 10 + 4);
DFS(x * 10 + 7);
}
bool lucky(long long x) {
do {
int cur = x % 10;
if (cur !=... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.io.*;
import java.util.*;
import java.math.*;
public class p1251D {
public class Emp implements Comparable<Emp>{
public long l;
public long r;
public long s;
public Emp (long l, long r, long s) {
this.l = l;
this.r = r;
this.s = s;
}
public int compareTo(Emp e) {
if(this.l < e.... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int cas, n;
pair<long long, long long> a[maxn];
long long k;
bool chk(long long mid) {
long long tmp = 0;
int pos = n / 2 + 1;
for (int i = 1; i <= n; i++) {
if (a[i].second >= mid && pos) {
tmp += max(mid, a[i].first);
pos--... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.net.Inet4Address;
import java.util.*;
import java.lang.*;
import java.util.HashMap;
import java.util.PriorityQueue;
public class Solution implements Runnable{
static class pair implements Comparable
{
int f;
... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
const long long inf = (long long)1e18 + 7;
const long long Mod = (long long)998244353;
using namespace std;
long long modexpo(long long a, long long b) {
long long ret = 1;
while (b) {
if (b & 1) {
ret = (ret * a) % Mod;
}
a = (a * a) % Mod;
b >>= 1;
}
return ret;
... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import sys
from bisect import bisect_left
# inf = open('input.txt', 'r')
# reader = (line.rstrip() for line in inf)
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
n, s = map(int, input().split())
mid = n >> 1
rl = []
for i in range(n):
... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long int inf = 9e18;
const long double pi = 2 * acos(0.0);
long long int tes, n, s;
vector<pair<long long int, long long int>> arr;
long long int power(long long int x, long long int y) {
long long int res = 1ll;
while (y > 0) {
if (y & 1) res = res * x;
... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import sys
input1 = sys.stdin.readline
def solve():
n, s = [int(i) for i in input1().split()]
empl = []
for i in range(n):
empl.append([int(j) for j in input1().split()])
empl.sort(reverse = True)
lg = 0
rg = 10 ** 9 + 1
while rg - lg > 1:
mg = (rg + lg) // 2
need = ... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
struct node {
int l, r;
} a[N];
bool operator<(const node& a, const node& b) { return a.l > b.l; }
long long n, s;
bool check(long long x) {
long long i = 0, k = 0, sum = 0;
while (k < n / 2 + 1) {
i++;
if (i > n) break;
if (a[i].r <... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | 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 ... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <class T>
int read(T& x) {
int c = getchar(), f = (x = 0);
while (~c && (c < 48 || c > 57)) {
if (c == '-') {
f = 1;
}
c = getchar();
}
if (!~c) {
return 0;
}
while (c > 47 && c < 58) {
x = (x << 3) + (x << 1) + (c ^ 48), c = g... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | 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_ += x - l
if cur == num and sum_ <= s:
... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long t, n, s, l, r, mid, sum, ans, answer;
pair<long long, long long> p[200005];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> t;
for (int rr = 0; rr < t; rr++) {
cin >> n >> s;
for (int i = 0; i < n; i++) {
cin >> p... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import sys
def BinSearch():
pass
t = int(sys.stdin.readline())
for _ in range(t):
n, s = map(int, sys.stdin.readline().split())
tmp = [tuple(map(int, sys.stdin.readline().split())) for _ in range(n)]
mid = s
r = s
l = 0
tmp.sort()
while True:
tp = []
tp1 = 0
tmp... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
const long long int inf = 9e18;
const long double pi = 2 * acos(0.0);
using namespace std;
long long int power(long long int a, long long int n) {
if (n == 0) {
return 1;
}
long long int p = power(a, n / 2) % 1000000007;
p = (p * p) % 1000000007;
if (n % 2 == 1) {
p = (p * a) ... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline long long rand(long long x, long long y) {
return (rng() % (y + 1 - x)) + x;
}
string to_string(char c) {
string second(1, c);
return second;
}
template <typename T>
inline T gcd(T a, T b) {
... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | 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.Comparator;
import java.util.NoSuchElement... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.io.*;
import java.util.*;
@SuppressWarnings("unused")
public class Main {
private FastScanner in;
private PrintWriter out;
final int MOD = (int)1e9+7;
long ceil(long a, long b){return (a + b - 1) / b;}
long gcd(long a, long b){return b == 0 ? a : gcd(b, a % b);}
long lcm(long a, lon... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | #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... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import sys
input = sys.stdin.readline
t=int(input())
for test in range(t):
n,s=map(int,input().split())
LR=[tuple(map(int,input().split())) for i in range(n)]
LR.sort(reverse=True)
R=[r for l,r in LR]
R.sort()
#print(LR,R)
MIN=LR[n//2][0]
MAX=R[n//2]
OK=(n+1)//2
while... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
using LL = long long;
int T, n;
LL s, l[200005], r[200005], bufl[200005];
bool check(LL x) {
int a = 0, b = 0, c = 0;
LL sa = 0;
for (int i = 1; i <= n; i++)
if (r[i] < x)
++a, sa += l[i];
else if (l[i] <= x)
++b, bufl[b] = l[i];
else
++c... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #Code by Sounak, IIESTS
#------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threadi... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.util.*;
import javax.imageio.ImageIO;
import javax.xml.bind.DatatypeConverter;
import java.awt.image.BufferedImage;
import java.io.*;
import java.math.BigInteger;
public class template {
public static void main(String[] args) throws Exception {
FastScanner sc = new FastScanner();
PrintWriter pw = new... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> emp;
int n;
long long s, minS;
bool bSearch(long long t) {
int neededBigger = n / 2 + 1;
long long curS = s - minS;
for (int i = emp.size() - 1; i >= 0 && neededBigger > 0; i--) {
if (emp[i].first >= t) {
neededBigger--;
... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 6;
const long long MOD2 = 1e9 + 7;
const long long MOD = 998244353;
long long s;
pair<long long, long long> a[N];
int n;
int qan;
bool check(long long v) {
long long ans = 0;
qan = n / 2 + 1;
for (int i = (n)-1; i >= 0; i--) {
if (a[i].first > ... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | /*Author: Satyajeet Singh, Delhi Technological University*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.math.*;
public class Main{
/*********************************************Constants******************************************/
static PrintWriter ... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
void optimise() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
bool compare(pair<long long int, long long int> X,
pair<long long int, long long int> Y) {
if (X.second < Y.second)
return 1;
else if (Y.second < X.second)
return 0;
else {
... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 |
import java.io.*;
import java.util.*;
public class temp1 {
public static PrintWriter out;
static int o = 0, e = 0;
static int[] fa;
static int[][][][] dp;
static ArrayList<Integer>[] a;
static int ans = 0;
public static void main(String[] args) throws IOException {
Reader scn = new Reader();
int t = ... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
n, s = map(int, input().split())
L = [0]*n
R = [0]*n
RL = [0]*n
for i in range(n):
l, r = map(int, input().split())
L[i] = l
R[i] = r
RL[i] = (r, l)
L.sort()
R.sort()
#RL.sor... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main{
public static class FastReader {
BufferedReader br;
StringTokenizer root;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (root == null || !root.hasMore... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 1e18;
vector<pair<long long, long long> > a;
int n;
long long s;
long long check(long long m) {
int countt = a.size() / 2 + 1;
long long sum = 0;
for (int i = 0; i < a.size(); i++) {
if (a[i].first <= m && a[i].sec... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
void fast() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
const long long mas = 200000 + 10;
long long l[mas], r[mas];
long long num[mas];
bool cmp(int x, int y) { return l[x] < l[y]; }
int main() {
fast();
long long t;
cin >> t;
long long n, ... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.io.*;
import java.util.*;
public class LabAlgoOne {
//Scanner
static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
static String currentInputLine = "";
static String inputFi... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): ... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.util.*;
import java.io.*;
public class D {
boolean ok(long MEAN, long S, long[][] interv){
PriorityQueue<Long> pq = new PriorityQueue<>();
long SUM = 0;
int N = interv[0].length;
int to_add = N/2 + 1;
int no_above = 0;
for(int i = 0; i<N; i++) {
... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | import sys
import math
from collections import defaultdict
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
read = lambda : map(int, input().split())
def write(*args, sep="\n"):
for i in args:
sys.stdout.write("{}".format(i) + sep)
INF = float('i... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
N, S = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(N)]
Query.append((N, S, LR))
for N, S, LR in Query:
G = []
for L, _ in LR:
G.append(L)
G.sort()
l = G[N//2]
... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long n, i, j, x, t, y, s;
cin >> t;
while (t--) {
cin >> n >> s;
vector<pair<long long, long long> > v;
long long lo = 1e18, mid, hi = 0;
for (i = 0; i < n; i++) {
cin >> x >> y;
... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, s;
vector<pair<ll, ll>> v;
bool ok(ll x) {
ll ns = 0, cnt = 0;
vector<ll> vx;
for (ll i = 0; i < n; ++i) {
if (v[i].second < x) {
ns += v[i].first;
} else if (v[i].first >= x) {
ns += v[i].first;
cnt++;
} else
... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
bool can(long long mid, vector<pair<long long, long long>> &f, long long n,
long long s) {
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)... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
template <typename T>
void scan(T& a) {
cin >> a;
}
template <typename T, typename... Args>
void scan(T& t, Args&... a) {
scan(t);
scan(a...);
}
template <typename T>
void debug(T a) {
cou... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7, MAX = 2e5 + 2;
int n;
long long sum, res;
vector<pair<long long, long long>> v;
int b_s(long long beg, long long end) {
if (beg > end) return 0;
long long mid = (beg + end) / 2, total = sum;
int cnt = 0;
vector<pair<long long, long lon... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Comparator;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution i... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | from sys import stdin
from sys import setrecursionlimit as SRL
SRL(10 ** 7)
rd = stdin.readline
rrd = lambda: map(int, rd().strip().split())
q = int(input())
lr = []
def check(x, s):
cnt = 0
tt = []
xcnt = 0
for l, r in lr[::-1]:
if l>x:
tt.append(l)
cnt += 1
... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 2;
int t;
int n;
ll s, a[N];
pair<ll, ll> seg[N];
vector<ll> vs;
int main() {
ios::sync_with_stdio(false);
cin >> t;
while (t--) {
cin >> n >> s;
for (int i = 1; i <= n; ++i) {
cin >> seg[i].first >> seg[i].secon... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, s = map(int, input().split())
human = []
x = n//2 + 1
for _ in range(n):
human.append(list(map(int, input().split())))
human.sort(reverse = True)
remain = s
for i in range(n):
remain -= human[i][0]... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | #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... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import sys
import math
from collections import defaultdict
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
read = lambda : map(int, input().split())
def write(*args, sep="\n"):
for i in args:
sys.stdout.write("{}".format(i) + sep)
INF = float('i... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int n;
long long s;
int x[MAXN], y[MAXN];
int tot, cnt, z[MAXN];
inline bool Check(int sl) {
tot = cnt = 0;
long long sum = 0;
for (int i = 1; i <= n; i++) {
if (y[i] >= sl) {
if (x[i] >= sl)
cnt++, sum += x[i];
else
... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
template <class T>
inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T>
inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
namespace flyinthesky {
const int MAXN = 200000 + 5;
long long n, s, ll[MAXN], rr[MAXN];
long long tot, orz[MAXN];
struct qj {
long long l, r;
} itv[MAXN];
bool chk(long long x) {
long long gg1 = 0, gg2 = 0, gg3 = 0;
for (int i = 1; i <= n; ++i) {
if (itv[i].r < x... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 |
import java.io.*;
import java.util.*;
public class D1251
{
static boolean check(pair a[],int n,int med,long v)
{
long req=0;List<Integer> ind=new ArrayList<>();int c=0;
for(int i=0;i<n;i++)
{
if(a[i].right<med)
{
c++;
req+=a[i].l... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 2;
vector<pair<long long, long long>> v(N);
long long n, s;
bool check(long long mid) {
long long cnt = 0, sum = 0;
vector<long long> tmp;
for (long long i = 0; i < n; i++) {
if (mid > v[i].second)
sum += v[i].first;
else if (mi... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.io.*;
import java.util.*;
public class Main {
static FastReader in;
static PrintWriter out;
static void solve() {
int n = in.nextInt();
long s = in.nextLong();
long[][] a = new long[n][2];
long l = (long) 1e9, r = 1;
for (int i = 0; i < n; i++) {
... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;
import java.lang.Math;
public class Solution {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;
static long mod = 998244353;
public stati... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args) throws Exception{
MScanner sc=new MScanner(System.in);
PrintWriter pw=new PrintWriter(System.out);
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();long s=sc.nextLong();
int[][]ranges=new int[n][2];
... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | // package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class AS4 {
public static void main(String[] Args){
FastReader scan=new FastReader();
int t=scan.nextInt();
StringBuilder print=new StringBuilder();
... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | import sys
#import heapq as hq
#sys.stdin = open('in', 'r')
readline = sys.stdin.readline
rdw = lambda: readline().split()
rdwl = lambda: list(readline().split())
rdi = lambda: int(readline())
rdis = lambda: map(int, readline().split())
rdisl = lambda: list(map(int, readline().split()))
rdrows = lambda cnt: [tuple(rdis... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.AbstractCollection;
import java.util.SplittableRandom;
import ja... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50;
struct Node {
int l, r;
bool operator<(const Node& b) const { return l > b.l; }
};
Node a[N];
bool check(int x, int n, long long s) {
int m = 0;
long long sum = 0;
for (int i = 1; i <= n; i++) {
if (a[i].l > x) {
m++;
sum +=... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
public static void main(String[] args) {
Problems problems = new Problems();
problems.solve();
}
}
class Problems {
Parser parser = new Parser();
void... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long N = 2000005;
const long long M = 1e9 + 7;
int n;
long long s;
vector<pair<int, int> > v;
vector<int> a, b;
bool check(int x) {
vector<int> t;
int a = 0, b = 0;
long long ss = 0;
for (int i = 0; i < n; i++) {
if (v[i].second < x) {
a++;
... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
static int inf = (int) 1e9 + 7;
static int n, l[], r[];
static long s;
static boolean f(int mid) {
long sum = 0;
int cnt = 0;
for(int i = 0;i < n;i++) {
if (r[i] < mid) {
... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | import sys,os,io
input = sys.stdin.readline
PI = 3.141592653589793238460
INF = float('inf')
MOD = 1000000007
# MOD = 998244353
def bin32(num):
return '{0:032b}'.format(num)
def add(x,y):
return (x+y)%MOD
def sub(x,y):
return (x-y+MOD)%MOD
def mul(x,y):
return (x*y)%MOD
def gcd(x,y):
if y ==... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | /* Rajkin Hossain */
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class D{
FastInput k = new FastInput(System.in);
//FastInput k = new FastInput("C:/Users/rajkin.h/Desktop/input.txt");
FastOutput z = new FastOutput();
int n;
long s;
Pair [] cor;
... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
t = int(input())
def check(v,arr,s,n):
l1 = 0
l2 = 0
num ... | PYTHON |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
typedef int (*uniopi)(int);
typedef long long (*uniopl)(long long);
typedef int (*binopi)(int, int);
typedef long long (*binopl)(long long, long long);
typedef int (*tupopi)(int, int, int);
typedef long long (*tupopl)(long long, long long, long long);
const long double PI =... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.util.Collec... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.util.*;
import java.io.*;
public class Main{
public static void main (String args[])throws IOException{
Scanner sc = new Scanner();
PrintWriter out = new PrintWriter(System.out);
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt(), r=1, l=(int)1e9, mid;
long s = sc.nextLong();
Pair... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | import sys
import math
from collections import defaultdict
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
read = lambda : map(int, input().split())
def write(*args, sep="\n"):
for i in args:
sys.stdout.write("{}".format(i) + sep)
INF = float('i... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long mx = 200005;
bool comparator(pair<long long, long long> A, pair<long long, long long> B) {
return A.first < B.first;
}
int main() {
ios::sync_with_stdio(0);
long long q;
cin >> q;
while (q--) {
long long n, s;
long long l;
long long r;
... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 2;
pair<long long, long long> sal[N];
bool solve(long long m, long long to, long long n) {
long long sum = 0;
int cnt = 0, rem, i;
vector<long long> ss;
for (i = 0; i < n; i++) {
if (sal[i].second < m)
sum += sal[i].first;
els... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct par {
ll l;
ll r;
};
int n;
ll s;
par mas[200100];
bool cmp(par a, par b) { return (a.l < b.l); }
bool good(ll m) {
vector<par> grp1;
vector<par> grp2;
vector<par> grp3;
for (int i = 0; i < n; i++) {
if (mas[i].r < m)
grp1.... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;
public class D1251 {
public static void main(String[] args){
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader ... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int t, n;
long long s;
pair<int, int> x[N];
bool valid(int mid) {
int cnt = (n + 1) / 2;
long long sum = s;
for (int i = n - 1; ~i; --i) {
if (cnt && mid <= x[i].second)
--cnt, sum -= max(x[i].first, mid);
else
sum -= x[i].fi... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import sys
readline = sys.stdin.readline
read = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')
def solve():
n, s = nm()
m = (n + 1)//2
emp ... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long n, s;
vector<pair<long long, long long> > r;
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
return a.first < b.first;
}
bool poss(long long cost) {
long long i;
long long tc = 0;
vector<pair<long long, long long> > rem;
long long... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.util.*;
import java.io.*;
public class Pmain0 {
static int t, n;
static long s;
static Pair a[];
static boolean v[];
static FastReader input = new FastReader();
static PrintWriter out = new PrintWriter(System.out);
static boolean p(int m) {
int more = (n + 1) / 2;
long tmps = s;
for (int i ... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Comparator;... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
using namespace std;
template <class T, class U>
inline void checkmin(T &x, U y) {
if (y < x) x = y;
}
template <class T, class U>
inline void checkmax(T &x, U y) {
if (y > x) x = y;
}
template <class T, class U>
inline b... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #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 +... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
struct Node {
long long l, r;
} dict[maxn];
long long N, s;
inline bool check(long long mid) {
long long cnt = 0, cost = 0;
priority_queue<long long, vector<long long>, greater<long long>> q;
for (int i = 1; i <= N; ++i) {
cost += dict... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #!/usr/bin/env python3
import sys
INF = 10**9
sys.setrecursionlimit(10**8)
input = sys.stdin.buffer.readline
t = int(input())
for i in range(t):
n, s = [int(item) for item in input().split()]
lr = []
for j in range(n):
l, r = [int(item) for item in input().split()]
lr.append((l, r))
lft... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
struct Sal {
int32_t min, max;
};
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int32_t tests;
cin >> tests;
for (int32_t test = 0; test < tests; test++) {
int32_t count;
int64_t total;
cin >> count >> total;
Sal s... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const double pai = acos(-1);
const double eps = 1e-10;
const long long mod = 1e9 + 7;
const int MXN = 1e6 + 5;
long long a[MXN], b[MXN];
int vis[MXN];
int n;
long long s;
struct no {
long long l, r, p;
};
bool operator<(const no &x, const no &y) { return x.l > y.l; }
bool... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <class T>
int read(T& x) {
int c = getchar(), f = (x = 0);
while (~c && (c < 48 || c > 57)) {
if (c == '-') {
f = 1;
}
c = getchar();
}
if (!~c) {
return 0;
}
while (c > 47 && c < 58) {
x = (x << 3) + (x << 1) + (c ^ 48), c = g... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import bisect
import os, sys, atexit
from io import BytesIO, StringIO
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
_OUTPUT_BUFFER = StringIO()
sys.stdout = _OUTPUT_BUFFER
@atexit.register
def write():
sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
def solve():
t = int(input())
for _ in ra... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 |
def main():
def getLowestPossibleMedian(lr,n):
lr.sort(key=lambda x:x[0]) # sort by l asc
return lr[n//2][0]
def checkPossibleMedian(lr,guess,n,s):
potentialUpper=[] # potential candidates for the upper half
lower=[]
lowerCnts=n//2
upperCnts=n-lowerCnts... | PYTHON3 |
1251_D. Salary Changing | 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 ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
const long long N = 2e5;
long long po(long long, long long);
vector<pair<long long, long long>> v;
long long n, s;
bool check(long long mid) {
long long sum = 0;
long long c = 0;
for (long long i = n - 1; i >= 0; i--) {
if (mid >= v[i]... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Salary_changing_simple_binary_search {
public static void main(... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 | #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... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | #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 ... | CPP |
1251_D. Salary Changing | 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 ... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.*;
public class Main {
static Comparator<long[]> comparator_r =... | JAVA |
1251_D. Salary Changing | 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 ... | 2 | 10 |
import java.io.*;
import java.util.*;
public class e2
{
public static void print(String str,long val){
System.out.println(str+" "+val);
}
public long gcd(long a, long b) {
if (b==0L) return a;
return gcd(b,a%b);
}
public static void debug(long[][] arr){
int len =... | JAVA |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.