description stringlengths 35 9.39k | solution stringlengths 7 465k |
|---|---|
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
long long n, s, a[10000], ans, sum, mn = 1e15;
int main() {
cin >> n >> s;
for (int i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
mn = min(mn, a[i]);
}
if (sum < s) {
cout << "-1" << endl;
} else {
for (int i = 0; i < n; i++)
if (a[i] > ... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
class Timer {
clock_t start;
string name;
public:
Timer() {
name = "";
start = clock();
}
Timer(string s) {
name = s;
start = clock();
}
~Timer() {
fprintf(stderr, "%s: %.3gs\n", name.c_str(),
1.0 * (clock() - start) / CLOCKS_... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import java.util.Scanner;
public class B1084 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
long S = in.nextLong();
long total = 0;
long min = Integer.MAX_VALUE;
for (int n=0; n<N; n++) {
long v = in... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #In the name of GOD!
n, s = map(int, input().split())
v = list(map(int, input().split()))
mn = min(v)
sm = cnt = 0
for i in range(n):
sm += v[i]
cnt += (v[i] - mn)
if sm < s:
print(-1)
elif s <= cnt:
print(mn)
else:
print(mn - ((s - cnt) // n) - min(1, (s - cnt) % n))
|
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | I = lambda: map(int, input().split())
n, s = I()
V = list(I())
V_min = min(V)
V = sum(V)
print(-1 if V < s else min(V_min, (V-s)//n)) |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
long long n, s, v[1234], mn, mx = 1e9, sum;
long long liters(long long md) {
long long tmp = 0;
for (int i = 0; i < n; i++) tmp += max(v[i] - md, 0ll);
return tmp;
}
int main() {
cin >> n >> s;
for (int i = 0; i < n; i++) cin >> v[i], sum += v[i], mx = min(mx, v[i... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | def func(s,n,vols):
if s > sum(vols):
return -1
minInd = 0
for i in range(1,len(vols)):
if vols[i] < vols[minInd]:
minInd = i
minAmt = vols[minInd]
for i in range(len(vols)):
vols[i] -= minAmt
remainingSum = sum(vols)
if remainingSum >= s:
return minAmt
totalLeft = s - remainingSum
if totalLeft % n ... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import sys
input=sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import PriorityQueue as pq
n,s=map(int,input().split())
l=list(ma... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
long long int ok(long long int n, long long int k) {
if (n % k == 0)
return (n / k);
else
return (n / k) + 1;
}
long long int ll_sum(long long int n) {
long long int sum = 0;
while (n != 0) sum += (n % 10), n /= 10;
return sum;
}
long long int str_sum(stri... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m;
while (cin >> n >> m) {
long long num, sum = 0, minx = 1000000001;
for (long long i = 0; i < n; i++) {
cin >> num;
sum += num;
if (num < minx) minx = num;
}
if (sum < m)
cout << -1 << endl;
else if... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long int INF = 9e18 + 2e17;
const int inf = 2e9;
const double eps = 1e-10;
int main(int argc, char const *argv[]) {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
long long int s;
cin >> n >> s;
vector<in... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import java.io.*;
import java.util.StringTokenizer;
public class Main {
private static long MODULO = 1000245997;
private FastScanner in;
private PrintWriter out;
public static void main(String[] args) {
try {
(new Main()).run();
} catch (IOException e) {
e.print... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import sys
def fi():
return int(sys.stdin.readline())
def fi2():
return map(int, sys.stdin.readline().split())
def fi3():
return sys.stdin.readline()
def fo(*args):
for s in args:
sys.stdout.write(str(s)+' ')
sys.stdout.write('\n')
INF=10**9+7
#main
n,s=fi2()
k=raw_input().split()
k=[i... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n,s=map(int,input().split())
a=[int(i) for i in input().split()]
mini=min(a)
t=0
for i in range(n):
t=t+a[i]-mini
if(t>=s):
print(mini)
elif(s>sum(a)):
print("-1")
else:
rem=s-t
if(rem//n==rem/n):
k=rem//n
print(mini-k)
else:
k=rem//n+1
print(mini-k)
... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | a,b=map(int,input().split())
l=list(map(int,input().split()))
summa=sum(l)
need=0
if summa<b:
print(-1)
elif summa==b:
print(0)
else:
need=summa-b
print(min(min(l),need//a)) |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n, s = input().split()
n = int(n)
s = int(s)
arr = input().split()
for i in range(n):
arr[i] = int(arr[i])
minim = min(arr)
count = arr.index(minim)
max = 0
for i in range(n):
max += arr[i]
flag = 0
if s > max:
print('-1')
else:
for i in range(n):
s -= arr[i] - minim
if s <= 0:
pri... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
/**
* @author Andrei Chugunov
*/
public class Main {
private static class Solution {
private void solve(FastScanner in, PrintWriter out) {
int n = in.nextInt();
long s = in.nextLong();
int[] ... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n,s=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
sum=0
min=a[0]
for i in range(n):
if(min>a[i]):
min=a[i]
sum+=a[i]
if(sum<s):
print("-1")
else:
if(sum==s):
print("0")
else:
if(s<=(sum-n*min)):
print(min)
else:
s-=(sum-... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
long long int s;
cin >> s;
long long int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr, arr + n);
long long int smallest = arr[0];
long long int sum = 0;
for (int i = 0; i < n; i++) {
sum = sum + ... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template <class T>
void na(vector<T>& a, int n) {
a = vector<T>(n);
for (T& i : a) cin >> i;
}
template <class T>
void printVector(vector<T>& a) {
for (T& i : a) cout << i << ' ';
cout << '\n';
}
template <class T>
vector<T> shrink(vect... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... |
from sys import stdin, stdout
n, s = map(int, stdin.readline().split())
v = list(map(int, stdin.readline().split()))
ans = -1
if sum(v) < s:
ans = -1
else:
mnm = min(v)
for i in range(n):
if v[i] > mnm:
if s - v[i] + mnm <= 0:
ans = mnm
s = 0
... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n, s = [int(x) for x in input().split(' ')]
v = [int(x) for x in input().split(' ')]
if sum(v) < s:
ans = -1
else:
ans = min(min(v), (sum(v) - s) // n)
print(ans)
|
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFLL = 1e18;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
long long a[MAXN];
int n;
long long s;
int main() {
scanf("%d", &n);
scanf("%lld", &s);
for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
sort(a, a + n);
f... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int mod = 1e9 + 7;
long long n, a[1005];
long long s;
int ck(long long x) {
long long minn = x, now = 0, flag = 0;
for (int i = 1; i <= n; i++) {
if (a[i] >= x) {
now += a[i] - x;
} else {
flag = 1;
break;
}
... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n,s = map(int,raw_input().split(" "))
arr = map(int,raw_input().split(" "))
if sum(arr)<s:
print -1
else:
minv = min(arr)
ss = sum(arr)
if ss-minv*n >=s:
print minv
else:
print (ss-s)/n
|
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | from os import path
import sys,time
# mod = int(1e9 + 7)
# import re
from math import ceil, floor,gcd,log,log2 ,factorial
from collections import defaultdict ,Counter , OrderedDict , deque
from itertools import combinations , groupby , zip_longest,permutations
# from string import ascii_lowercase ,ascii_uppercase
from ... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import sys
input = sys.stdin.readline
from collections import *
def judge(x):
s2 = sum(vi-x for vi in v)
return s2>=s
def binary_search():
l, r = 0, min(v)
while l<=r:
m = (l+r)//2
if judge(m):
l = m+1
else:
r = m-1
return r
n, s ... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n,v=(int(i)for i in input().split())
a=[int(i)for i in input().split()]
mina=min(a)
vm=sum(a)-n*mina
if v<=vm:
print(mina)
elif sum(a)>=v>vm:
print(mina+(-(v-vm))//n)
else:
print('-1')
|
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | from sys import stdin
n,s = map(int,stdin.readline().split())
a = map(int,stdin.readline().split())
def solve(x):
cur = 0
for i in a:
if i < x:
return 0
cur += (i-x)
if cur >=s:
return 1
return 0
if sum(a) < s:
print -1
else:
lo = 0
hi = 10**12
w... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* @author Don Li
*/
public class KvassAndTheFairNut3 {
void solve() {
int n = in.nextInt(); long s = in.nextLong();
int[] v = new int[n];
... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | from math import ceil
import sys
n, s = map(int, input().split())
v = list(map(int, input().split()))
if s > sum(v):
print(-1)
sys.exit(0)
m = min(v)
s -= sum(v) - m * n
if s < 0:
print(m)
sys.exit(0)
print(m - ceil(s / n))
|
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import java.util.*;
import java.io.*;
import java.math.*;
public class Prg4 {
PrintWriter pw = new PrintWriter(System.out);
Random rnd = new Random();
int a;
void run(){
int a = ni();
long s = nl(), all=0;
long[] m = new long[a], sum = new long[a];
for(int q=0; q<a; q+... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import sys, math
from sys import stdin, stdout
rem = 10 ** 9 + 7
inf=10**18
#sys.setrecursionlimit(10 ** 6 + 7)
#from resource import *; setrlimit(RLIMIT_STACK, (RLIM_INFINITY, RLIM_INFINITY))
take = lambda: map(int, stdin.readline().split())
from heapq import heappush, heappop, heapify
from collections import deque
fr... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1025;
long long p[MAX_N];
int main() {
long long s, n, sum = 0;
scanf("%lld%lld", &n, &s);
for (int i = 1; i <= n; ++i) scanf("%lld", &p[i]), sum += p[i];
sort(p + 1, p + 1 + n);
if (sum < s) {
printf("-1\n");
return 0;
} else {
lon... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n, s = map(int, input().split())
v = list(map(int, input().split()))
if sum(v) >= s:
c = min(v)
for i in range(n):
s -= (v[i] - c)
v[i] = c
if s<=0:
print(v[0])
else:
print(v[0]-(s+n-1)//n)
else:
print(-1) |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
long long mod = (long long)1e17 + 7;
long long n, s, v[1005], sum = 0, mn = mod;
long long foo(long long mid) {
long long r1 = sum - (n * mid);
if (r1 >= s)
return 1;
else
return 0;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... |
n, s = map(int, input().split())
tab = sorted([int(x) for x in input().split()])
best = -1
if sum(tab) >= s:
s -= sum(tab) - tab[0] * len(tab)
best = min(tab[0], tab[0] - (s + len(tab) - 1) // len(tab))
print(best)
|
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n,s = tuple(map(int, input().split()))
min = 2000000000
arr = list(map(int, input().split()))
for i in range(n):
if (arr[i] < min):
min = arr[i]
sum = 0
for i in range(n):
sum = sum + (arr[i] - min)
flag = 0
if (sum >= s):
print(min)
else:
tmp = s - sum
tmpMin = tmp // n
if(min < tmpMin)... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
long long n;
cin >> n;
long long s;
cin >> s;
long long sum = 0;
long long mi;
cin >> mi;
sum += mi;
for (long long i = 1; i < n; i++) {
long long t;
cin >> t;
mi = min(mi, t);
sum += t;
}
sum -= ... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n, s = map(int, input().split())
a = [int(i) for i in input().split()]
x = sum(a)
if x >= s:
print(min((x - s) // n, min(a)))
else:
print('-1') |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | def check(sum, n, x, s):
if sum - n * x >= s:
return True
else:
return False
def main():
n, s = map(int, input().split())
sum = 0
minval = 999999999999
a = input().split()
for i in range(n):
sum += int(a[i])
minval = min(minval, int(a[i]))
if sum < s:
... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
int main() {
int n = 0;
long long s = 0;
scanf("%d %lld", &n, &s);
long long kegs[n];
memset(kegs, 0, sizeof(kegs));
long long least = -1;
for (int i = 0; i < n; i++) {
int v = 0;
scanf("%d", &v);
kegs[i] = v;
least = (v < least || least == -1) ? v : least;
}
l... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;
long long int n, arr[nax];
int main() {
long long int s;
cin >> n >> s;
long long int mini = INF, tot = 0, left = 0;
for (int i = 1; i <= n; i++)
cin >> a... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
long long v[maxn];
int main() {
long long n, s;
scanf("%lld%lld", &n, &s);
long long sum = 0, minn = 1e9 + 7, x;
for (long long i = 0; i < n; i++)
scanf("%lld", &x), sum += x, minn = min(minn, x);
if (sum < s)
printf("-1\n");
el... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | 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... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.stream.LongStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
void IO(bool inp, bool out) {
if (inp) freopen("k.inp", "r", stdin);
if (out) freopen("k.out", "w", stdout);
}
using namespace std;
short n;
long long a[1001], s;
bool kt(long long u) {
long long t = 0;
for (short i = 1; i <= n; ++i)
if (a[i] < u)
return false;
else
... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
bool check(vector<long long int> a, long long int mid, long long int k,
long long int &ans) {
long long int n = a.size();
long long int temp = 0;
long long int c = a[n - 1];
;
for (long long int i = n - 1; i >= 0; i--) {
if (a[i] >= mid) {
tem... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n,s=[int(x) for x in input().split(' ')]
z=[int(x) for x in input().split(' ')]
z.sort()
if sum(z)<s:
print(-1)
elif n==1:
print(z[0]-s)
else:
a,f=0,0
for x in z[1:]:
a+=x-z[0]
if a>=s:
f=1
break
if f:
print(z[0])
else:
s-=a
if s%n=... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
int main() {
int n;
long long s;
long long a[1005];
scanf("%d%lld", &n, &s);
int i, j;
long long min = 1e9;
long long Sum = 0;
int flag = 0;
for (i = 0; i < n; i++) {
scanf("%lld", &a[i]);
if (a[i] < min) min = a[i];
Sum += a[i];
}
if (s > Sum) flag = 2;
long... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
int n, a[1001], mn = 1e9;
long long s, cnt = 0;
signed main() {
scanf("%d %lld", &n, &s);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
if (mn > a[i]) mn = a[i];
}
for (int i = 1; i <= n; i++) {
cnt += a[i] - mn;
}
printf("%lld",
(cnt >= s ? mn
... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import sys
from math import ceil
def main():
n, s = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
if s > sum(arr):
print(-1, sep=' ', end='\n', file=sys.stdout, flush=False)
else:
count = 0
arr.sort(reverse=True)
for i in rang... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n, s = map(int, input().split())
v = list(map(int, input().split()))
sm = sum(v)
sm -= s
if sm < 0:
print(-1)
else:
mn = min(v)
r = min(mn, sm // n)
print(r)
|
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
void Fast_Read_Out() {
ios_base::sync_with_stdio(0);
cin.tie(), cout.tie();
}
void Random() {
unsigned int seed;
asm("rdtsc" : "=A"(seed));
srand(seed);
}
unsigned int Time() {
unsigned int time = clock() / 1000.00;
return time;
}
const int inf = int(1e9) + 12... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
long long a[100000];
int main() {
long long n, s, sum = 0, ans, minn = 10000000000000;
cin >> n >> s;
for (int i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
if (a[i] < minn) minn = a[i];
}
if (sum < s) {
cout << "-1" << endl;
return 0;
}
l... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
stack<long long int> st;
long long int binarySearch(long long int l, long long int r, long long int a[],
long long int k) {
if (l <= r) {
long long int mid = l + (r - l) / 2;
if (a[mid] == k)
return mid;
else if (a[mid] > k)
... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | //package practice_codes;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Collectors;
//import codes.Reference.i;
public class KvassAndTheFairNut {
public static void main(String[] args) {
// ... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) throws Exception {
//Scanner in = new Scanner(System.in);
PrintWriter pw=new PrintWriter(System.out);
BufferedReader br = new Bu... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... |
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Try
{
static class InputReader {
private final InputStream stream;
private final byte[] buf = new byte[8192];
private int curChar, snumChars;
public InputReader(InputStream st)... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n, s = map(int, input().split())
a = [int(i) for i in input().split()]
if sum(a) < s:
print(-1)
exit()
if sum(a) - n * min(a) >= s:
print(min(a))
exit()
s -= sum(a) - n * min(a)
if s % n == 0:
print(min(a) - s // n)
else:
print(min(a) - s // n - 1) |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n,m=map(int,input().split())
l=list(map(int,input().split()))
s=0
d=min(l)
for i in l:
s=s+i
if(s<m):
print(-1)
else:
print(min(d,(s-m)//n))
|
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n, s = map(int, input().split())
us = input().split()
sum = 0
m = 10**9 + 1
for u in us:
sum += int(u)
if int(u) < m:
m = int(u)
if sum<s:
print(-1)
elif (sum-s)//n < m:
print((sum-s)//n)
else:
print(m) |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | a,b=map(int,input().split())
z=list(map(int,input().split()))
s=sum(z);r=min(z)
if b>s:print(-1)
elif s-r*a>=b:print(r)
else:
f=b-(s-r*a)
print((r-(f//a))-(0 if f%a==0 else 1)) |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... |
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;
public class BRound526 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
new BRound526 ().solve(in,out);
in.close();
... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import math, sys
n, s = map(int, input().split())
minval = math.inf
c = 0
l = list(map(int, input().split()))
add = sum(l)
if add < s:
print(-1)
sys.exit()
for i in range(0, n):
v = l[c]
minval = min(v , minval)
c+=1
var = (add - s) / n
print(int(min(var , minval)))
|
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n,s=map(int,input().split())
x=list(map(int,input().split()))
m=-1
if sum(x)>=s:
x=sorted(x,reverse=True)
m=x[n-1]
for i in x:
if s<=0:
break
if i==m:
import math
m-=math.ceil(s/n)
break
else:
s-=i-m
print(m) |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n = list(map(int,input().split()))
s = n[1]
n = n[0]
a = list(map(int,input().split()))
a = sorted(a,reverse = True)
k = min(a)
su = 0
if s > sum(a):
print(-1)
else:
for i in range(len(a)):
if a[i] > k:
su += (a[i]-k)
a[i] = k
if su >= s:
break
if... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | from math import ceil
n,s=map(int,input().split())
l=[int(i) for i in input().split()]
sm=sum(l)
m=min(l)
if s>sm:
print(-1)
exit()
print(min(m,(sm-s)//n)) |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... |
import java.util.Arrays;
import java.util.Scanner;
public class KvassandtheFairNut {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
long s = scan.nextLong();
long[] a = new long[n];
long sum = 0;
for (int i ... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, s, sum = 0;
cin >> n >> s;
vector<long long int> u(n);
for (long long int i = 0; i < n; i++) {
cin >> u[i];
sum += u[i];
}
if (sum < s) {
cout << "-1" << endl;
return 0;
}
sort(u.begin(), u.end());
for (long lo... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | def get_ans(n, s, a):
sum = 0
Min = int(1e9 + 1)
for elem in a:
sum += elem
Min = min(Min, elem)
if sum < s:
return -1
k = (sum - s) // n
return min(Min, k)
n, s = map(int, input().split())
a = list(map(int, input().split()))
print(get_ans(n, s, a)) |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import java.util.*;
public class KvassAndTheFruitNut{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long s = sc.nextLong();
long[] arr = new long[n+1];
long sum = 0;
for(int i=1; i<n+1; i++){
arr[i] = sc.nextLong();
sum += arr[i];
}
long min =0... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import java.io.*;
import java.util.*;
public class Main {
private static final int MAX = Integer.MAX_VALUE;
private static final int MIN = Integer.MIN_VALUE;
public static void main(String[] args) throws IOException {
InputStream inputStream = System.in;
OutputStream outputStream = System.... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import math
if __name__ == '__main__':
n,s = [int(x) for x in input().split()]
v = [int(x) for x in input().split()]
v.sort()
if sum(v) < s :
print(-1)
else :
ans = -1
if s <= sum(v) - min(v)*n:
print(min(v))
else :
s -= sum(v) - min(v)*n
v = [min(v)]*n
if s%n == 0 :
print(v[0] - s//n... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #!/usr/bin/python3
n, s = map(int, input().split())
values = list(map(int, input().split()))
m_v = min(values)
total = sum(values)
#no way
if total < s:
print ("{}".format(-1))
exit(0)
if total - n * m_v >= s:
# more than now
print ("{}".format(m_v))
exit(0)
# we have to decrease by rest all amount.... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import heapq as h
n, s = map(int, input().split())
v = list(map(int, input().split()))
v.sort()
if sum(v) < s:
print(-1)
else:
h.heapify(v)
i = -1
while i >= -n and s:
s -= min(s, v[i] - v[0])
v[i] -= min(s, v[i] - v[0])
i -= 1
v[0] -= s // n + (1 if s % n else 0)
print(... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n,s = map(int,input().split())
arr = list(map(int,input().split()))
mn= min(arr)
sm = sum(arr)
if sm < s:
print(-1)
elif(sm == s):
print(0)
else:
avg = (sm - s)//n
print(min(mn,avg)) |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, s, a[1001], somma = 0, minimo = 1000000001;
cin >> n >> s;
for (int i = 0; i < n; i++) {
cin >> a[i];
somma += a[i];
minimo = min(minimo, a[i]);
}
if (somma < s)
cout << -1;
else
cout << min(minimo, (somma - s) / n);... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... |
n, s = map(int, input().split())
arr = [int(x) for x in input().split()]
if sum(arr) < s:
print("-1")
exit()
mn = min(arr)
extra = sum([x-mn for x in arr])
if extra >= s:
print(mn)
else:
print(mn - ((s-extra+n-1)//n))
|
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... |
/**
* Date: 11 Dec, 2018
* Link:
*
* @author Prasad-Chaudhari
* @linkedIn: https://www.linkedin.com/in/prasad-chaudhari-841655a6/
* @git: https://github.com/Prasad-Chaudhari
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
//import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
Long s1 = s.nextLong();
Long w,min,idx;
Long t... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | from math import ceil
n,s=map(int,input().split())
a=list(map(int,input().split()))
if s>sum(a): print(-1)
else:
a.sort(reverse=True); i=0
sofa=0; mn=min(a)
while i<n and a[i]!=mn:
sofa+=a[i]-mn
i+=1
if sofa>=s: print(mn)
else:
diff=s-sofa
print(mn-ceil(diff/n)) |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
long long gcd1(long long a, long long b) {
if (a == 0) return b;
return gcd1(b % a, a);
}
long long modx(long long base, long long ex) {
long long ans = 1LL, val = base;
while (ex > 0LL) {
if (ex & 1LL) ans = (ans * val) % 1000000009LL;
val = (val * val) % 1... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e3;
const long long I = 1e18;
int n;
long long s, a[N], l = -1, r = I, c;
bool C(long long k) {
c = 0;
for (int i = 0; i < n; i++)
if (a[i] > k) c += a[i] - k;
return c >= s;
}
int main() {
cin >> n >> s;
for (int i = 0; i < n; i++) cin >> a[i];... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import java.io.*;
import java.util.*;
public class Codeforces1084B {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
StringTokenizer st = new StringTokenizer(br.readLine());
int... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
long long arr[1010];
int main() {
long long n;
long long s;
cin >> n >> s;
long long mini = (long long)1e15;
long long sum = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
mini = min(arr[i], mini);
sum += arr[i];
}
if (sum < s) {
cout << -1;... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | '''
3 3
4 3 5
'''
from math import *
def solve():
n, s = map(int, input().split())
l = list(map(int, input().split()))
answer = sum(l)
if n == 1 and s == l[0]:
return 0
if answer < s:
return -1
minn = min(l)
answer = 0
for i in range(len(l)):
if l[i] > minn:
... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.L... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n, s = [int(x) for x in input().split()]
data = [int(x) for x in input().split()]
total = sum(data)
diff = total - s
if diff < 0:
print(-1)
else:
# print(diff)
print(min(diff // n, min(data)))
|
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | n, left = map(int, input().split())
arr = list(map(int, input().split()))
if sum(arr) < left:
print(-1)
else:
mn = min(arr)
extra = 0
for v in arr:
extra += v - mn
if extra >= left:
print(mn)
else:
left -= extra
stages = left // n
if left % n != 0:
... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... |
import math
n,s = map(int,input().strip().split())
arr = list(map(int,input().strip().split()))
arr = sorted(arr)
c = 0
for i in range(n):
c+=arr[i]-arr[0]
#arr[i]=arr[i]-arr[0]
if c>=s:
print(arr[0])
else:
k = n
z = math.ceil((s-c)/k)
if z<=arr[0]:
print(arr[0]-z)
else:
... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | def check(arr,n,temp,s):
ans=0
for i in range(n):
if arr[i]>temp:
ans+=arr[i]-temp
if ans>=s:
return True
else:
return False
n,s=map(int,raw_input().split(" "))
l=map(int,raw_input().split())
if sum(l)<s:
print -1
exit()
mn=min(l)
l1=0
r1=mn
fin=0
while l1<=r1... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
long long a[1005];
int main() {
long long n, k, s = 0;
scanf("%lld%lld", &n, &k);
for (int i = 0; i < n; i++) {
scanf("%lld", &a[i]);
s += a[i];
}
if (k > s) {
printf("-1\n");
return 0;
}
if (n == 1) {
printf("%lld\n", a[0] - k);
return... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import sys, os
import math
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
if os.path.exists('input.txt'):
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
n,... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
long s = in.nextLong();
int[] a = new int[n];
long amin = 1_000_000_001;
for(int i=0; i<n; i++){
a[i] = in.n... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class Main implements Runnable {
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numCha... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import sys
line = sys.stdin.readline().strip().split()
n = int(line[0])
s = int(line[1])
ksum = 0
kmin = 10 ** 9 + 1
line = sys.stdin.readline().strip().split()
for i in range (0, n):
v = int(line[i])
ksum = ksum + v
kmin = min(kmin, v)
if ksum < s:
print(-1)
else:
print(min(kmin, (ksum - s) // n)... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | # x = int(input())
# m, n = map(int, input().split())
# nums = list(map(int, input().split()))
n,s=map(int,input().split())
a=list(map(int,input().split()))
minn=0x3f3f3f3f
sum=0
for i in range(n):
minn=min(minn,a[i])
sum+=a[i]
if sum<s:
print(-1)
else:
print(int(min(minn,(sum-s)/n)))
... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
long long n, s;
cin >> n >> s;
vector<long long> v(n);
long long sum = 0;
long long mn = 1e9 + 7;
for (int i = 0; i < n; ++i) {
cin >> v[i];
sum += v[i];
mn = min(mn, v[i]);
}
if (sum... |
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are v_i liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by s liters of kvass. But ... | import sys
def solve(io):
N = io.read_int()
S = io.read_int()
V = io.read_int_array(N)
L = 0
R = 1000000000
good = -1
while L <= R:
M = (L + R) // 2
if get_kvass(M, V) >= S:
L = M + 1
good = M
else:
R = M - 1
io.println(min(good, *V))
def get_kvass(x, V):
return sum([ val - x for val in V i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.