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 ...
import sys import math r = lambda: sys.stdin.readline() n, s = map(int,r().split()) arr = list(map(int, input().split())) cavas = 0 min_arr=min(arr) sum_arr=0 for i in range(n): sum_arr+=arr[i] cavas+=(arr[i]-min_arr) if s>sum_arr: print(-1) elif cavas>=s: print(min_arr) else: dd = ((s-cavas)/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; const long long INF = 100000000000000000; const long long MOD = 1000000007; const long long MAXN = 1005; long long dx[] = {0, 0, -1, 1, -1, -1, 1, 1}; long long dy[] = {1, -1, 0, 0, 1, -1, -1, 1}; vector<long long> v(MAXN); long long n, s; bool f(long long x) { long 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 ...
arr = list(map(int,input().strip().split(' '))) n = arr[0] s = arr[1] ss = 0 arr = list(map(int,input().strip().split(' '))) ss = sum(arr) if(ss<s): print(-1) else: ss = 0 arr.sort() for i in range(n): ss+=(arr[i]-arr[0]) if(ss>s): print(arr[0]) else: t = arr[0] - (s-ss+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 v[2000]; int main() { long long n, s, tot = 0; cin >> n >> s; for (int i = 0; i < n; ++i) { cin >> v[i]; tot += v[i]; } if (tot <= s) { if (tot < s) cout << "-1\n"; else cout << "0\n"; return 0; } sort(v, v + n); 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.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.util.LongSummaryStatistics; public class B { private static int cur, pos, len; private static int max, min, ans, res, sum; private static int ai, bi, ci, di; private...
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()) u = [int(x) for x in input().split()] su = sum(u) if su < s: print(-1) elif su == s: print(0) else: u.sort() print(min((su-s)//n, u[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 ...
#include <bits/stdc++.h> using namespace std; long long n, i, a, s, t, m = 2e9; int main() { for (cin >> n >> s; i < n; i++) cin >> a, t += a, m = min(m, a); if (t < s) return cout << -1, 0; if (t - m * n < s) return cout << (t - s) / n, 0; cout << 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 ...
import java.util.*; import java.io.*; public class CF1084B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long s = sc.nextLong(); long[] v = new long[n]; long sum = 0; for(int i = 0; i < n; i++) { 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 ...
import math (ns, ss) = '3 4'.strip().split(' ') (ns, ss) = input().strip().split(' ') n = int(ns) s = int(ss) vstr = '5 3 4'.strip().split(' ') vstr = input().strip().split(' ') v = list(map(int, vstr)) min_v = min(v) for i in range(n): if v[i] > min_v: s -= (v[i]-min_v) v[i] -= (v[i]-min_v) 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 ...
n, s = [int(x) for x in input().split()] barrel = [int(x) for x in input().split()] if sum(barrel) < s: print(-1) else: print(min(((sum(barrel) - s) // n), min(barrel)))
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, raw_input().split()) l = map(int, raw_input().split()) mini = min(l) if sum(l) < s: print -1 else: for i in l: s -= i - mini if s <= 0: print mini else: mini -= int(ceil(s/float(n))) print mini
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 Created : 6/10/2020 * Have A Good Day ! */ import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.PriorityQueue; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IO...
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 sortbysec(const pair<int, int> &a, const pair<int, int> &b) { if (a.first == b.first) return (a.second < b.second); return (a.first < b.first); } vector<long long int> prime(1000005, 1); void p() { long long int i, j; for (i = 2; i <= 1000000; i++) { if (pr...
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 sc =new Scanner(System.in); int n=sc.nextInt(); long v=sc.nextLong(); long sum=0; long min=Integer.MAX_VALUE; for(int i=0;i<n;i++) { int x=sc.nextInt(); sum+=x; min=Math.min(min, x); } if(sum<v) {...
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[10001], minn = 0x7fffffff, sum = 0, n, s; long long fmin(long long k1, long long k2) { if (k1 < k2) return k1; else return k2; } int main() { scanf("%lld%lld", &n, &s); for (long long i = 1; i <= n; i++) { scanf("%lld", &a[i]); minn = fmi...
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 ...
#include <bits/stdc++.h> using namespace std; long long a[1050]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m; cin >> n >> m; long long s = 0; for (int i = 0; i < (n); i++) { cin >> a[i]; s += a[i]; } if (s < m) { cout << -1; return 0; } sort(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.Scanner; public class CodeforcesFun { public static void main(String[] args) { Scanner myScanner = new Scanner(System.in); int n = myScanner.nextInt(); long s = myScanner.nextLong(); long[] arr = new long[n]; long min = Long.MAX_VALUE; for (int i = 0; i <= n - 1; i++) { arr[i] = mySca...
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 n, s=map(int, input().split()) a=[int(x) for x in input().split()] if (sum(a)<s): print (-1) else: m=min(a) free=0 for i in range(n): free+=(a[i]-m) a[i]-=m if (free>=s): print (m) sys.exit() s-=free print (m-math.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 ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1100; long long arr[maxn]; int n; long long s; int check(long long ck) { long long cur_sum = 0; for (int i = 1; i <= n; i++) { if (arr[i] < ck) return 0; cur_sum += (arr[i] - ck); } return cur_sum >= s; } int main() { long long sum = 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 = map(int, input().strip().split()) v = list(map(int, input().strip().split())) v.sort() izd = 0 if(sum(v) <s): print(-1) else: for i in range(len(v)): izd += v[i] - v[0] if(izd >= s): print(v[0]) else: x = (s - izd)/n if(int(x)==x): print(v[0]-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 = input().split(" ") data= [int(i) for i in input().split(" ")] s=sum(data) #print(s) if s<int(n[1]): s=-1 else: s-=int(n[1]) s//=int(n[0]) if min(data) <s: s= min(data) print(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, k = list(map(int, input().split(' '))) a = list(map(int, input().split(' '))) minV = min(a) s = sum(a) if(k > s): print(-1) else: rest = s - minV * n if(rest >= k): print(minV) else: k -= rest sol = k // n if(k % n): sol += 1 print(minV - sol)
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 in() { return; } template <typename T, typename... Types> void in(T &a, Types &...b) { cin >> (a); in(b...); } void o() { return; } template <typename T, typename... Types> void o(T a, Types... b) { cout << (a); cout << ' '; o(b...); } bool sortin(const pair<...
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 cont[1005]; int main() { ios::sync_with_stdio(0); long long n, m; cin >> n >> m; long long sum = 0; long long Min = 1e18; for (int i = 0; i < n; i++) { cin >> cont[i]; sum += cont[i]; Min = min(Min, cont[i]); } if (sum < m) { cout <...
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 = list(map(int, input().split())) a.sort() d = sum(a) if d >= s: r = d - s ans = min(r // n, a[0]) else: ans = -1 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 ...
import java.util.*; import java.lang.*; import java.io.*; public final class Kvass { static private Scanner sc = new Scanner(System.in); static public void main(String[] args) { int n = sc.nextInt(); long s = sc.nextLong(); long[] arr = new long[n]; long sum = 0; for(int i = 0;i<n; i++) { arr[i] = sc...
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 Kvass_Fair_Nut { public static void main (String args[]) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s[] =br.readLine().split(" "); int n = Integer.parseInt(s[0]); long g = Long.parseLong(s[1]); 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 ...
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Scanner; public class B_ { public static void main(String[] args) throws Exception { solve(); } // **SOLUTION** public static void solve() throws Exception { String[] ip = br.readLine().split(" "); int n = new Integer(ip[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,k=map(int,raw_input().split()) N=map(int,raw_input().split()) if sum(N)<k: print -1 exit(0) x=min(N) ret=0 for i in N: ret+=i-x if ret>=k: print x exit(0) k-=ret t=k/n if k%n!=0: t+=1 print x-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 ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ; long long i, j, k, t, mn = 1e13, x, sum = 0, temp, ans, s, n, baki; cin >> n >> s; vector<long long> vec; for (int i = 0; i < n; i++) { cin >> x; sum += x; vec.push_back(x); mn = min(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 java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
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 n; long long int s, sum = 0, mn = 1e9 + 9; vector<long long int> arr(1e3 + 3); int main(void) { ios ::sync_with_stdio(0); cin.tie(0); cin >> n >> s; for (int i = 1; i <= n; ++i) { cin >> arr[i]; sum += arr[i]; mn = min(mn, arr[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 ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.StringTokenizer; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() ...
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.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
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 B{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); long nb = sc.nextLong(); long qt = sc.nextLong(); long min = sc.nextLong(); long surplus = 0; long enCours; for (int i=1;i<nb;i++){ enCours=sc.nextLong(); if (enCours<min){ surplus ...
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 = [int(no) for no in input().split()] v = [int(no) for no in input().split()] min_v = min(v) current_available = sum([vi - min_v for vi in v]) if current_available >= s: print(min_v) else: rem = s - current_available # We have n kegs with min_v each # n * take >= rem # ...
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.lang.reflect.Array; 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 min=1000000000; long sum=0; for (int i=0;i<n;i++){ int temp=in.nextInt(); if (temp<min){ min=te...
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 floor n, s = tuple(int(i) for i in input().split(" ")) v_i = tuple(int(i) for i in input().split(" ")) v_sum = sum(v_i) if s>v_sum: print(-1) else: print(min(floor((v_sum - s)/n), min(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 ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n, k; cin >> n >> k; int a[n]; long long s = 0; for (int i = 0; i < (n); i++) { cin >> a[i]; s += a[i]; } if (k > s) { cout << "-1"; } else { 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 ...
""" this is a standard python template for codeforces task, repo: github.com/solbiatialessandro/pyComPro/codeforces """ stdin = lambda type_ = "int", sep = " ": list(map(eval(type_), raw_input().split(sep))) joint = lambda sep = " ", *args: sep.join(str(i) if type(i) != list else sep.join(map(str, i)) for i in args) de...
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; map<pair<pair<long long int, long long int>, pair<long long int, long long int>>, long long int> pqr; map<pair<long long int, long long int>, long long int> xyz; map<long long int, long long int, greater<long long int>> yz; vector<pair<long long int, string...
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, mn = 2e9, sum = 0; cin >> n >> s; long long a[1100]; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; mn = min(mn, a[i]); } if (sum < s) return cout << -1, 0; if (sum == s) return cout << 0, 0; if (sum - mn * 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()) v = sorted(list(map(int, input().split()))) if sum(v) < s: print(-1) else: remainder = (sum(v) - s) // n print(min(v[0], remainder))
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 ...
var numbers = readline().split(' '); var howMany = numbers[0]; var amountToFill = numbers[1]; howMany = parseInt(howMany) amountToFill = parseInt(amountToFill) var numberOfK = readline().split(' '); var asd = howMany+amountToFill var sum = 0, sumCheck = 0, minSumCheck = 0, check,ass check = Math.min.apply(null,numberO...
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 = list(map(int, input().split())) suma, mina = sum(a), min(a) if suma < s: print(-1) else: print(min((suma - s) // n, mina))
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 = [int(x) for x in input().split()] lst = [int(x) for x in input().split()] tot = sum(lst) if (s>tot): print(-1) exit() elif (s==tot): print(0) exit() s-=(tot-min(lst)*n) if (s<=0): print(min(lst)) exit() else: x=min(lst) if (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 ...
import math import sys input = sys.stdin.readline n, s = map(int, input().split()) v = list(map(int, input().split())) tot, mn = sum(v), min(v) if tot < s: ans = -1 else: res = 0 for i in range(n): if v[i] > mn: res += v[i] - mn v[i] -= mn if res >= s: ans = mn else: s -= res 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; 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 ...
(n,s)=map(int,input().split()) l=list(map(int,input().split())) sa=sum(l) sa-=s if sa<0: print(-1) else: sa//=n if min(l)<sa: print(min(l)) else: print(sa)
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, raw_input().split()) a = map(int, raw_input().split()) a.sort(reverse=1) if sum(a) < s: print - 1 else: x = sum(a) - n * a[-1] a = n * [a[-1]] if x >= s: print a[-1] else: y = int(ceil((s - x) / float(n))) print a[-1] - y
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 = input() n = int(x.split(" ")[0]) s = int(x.split(" ")[1]) x = input() x = x.split(" ") arr = [int(i) for i in x] if sum(arr)<s: print("-1") else: imin = min(arr) x = (sum(arr) - s)//n print(min(imin, x))
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 minimum(int a, int b) { if (a > b) return b; else return a; } int main() { int n; long long int s; cin >> n >> s; int v[n]; int min = 1000000000; long long int total = 0; for (int i = 0; i < n; i++) { cin >> v[i]; total = total + 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 ...
n, m = map(int, input().strip().split()) kegs = list(map(int, input().strip().split())) import math if sum(kegs) < m : print(-1) else : import operator index, value = min(enumerate(kegs), key=operator.itemgetter(1)) res = m for i, k in enumerate(kegs): if i != index: res -= k-value...
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()) v = map(int, raw_input().split()) if sum(v) >= s: m = min(v) c = 0 for x in v: c += x - m if c >= s: print m else: k = s - c h = (k / n) + (0 if k % n == 0 else 1) print m - h 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 ...
import math def max_min_volume(n, s, arr): arr.sort(reverse=True) cur_min = arr[-1] while (s > 0) and arr[-1] and (cur_min >= 0): for i in range(n-1, -1, -1): diff = arr[i] - cur_min if diff <= s: s -= diff arr[i] -= diff 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; long long binarySearch(long long arr[], long long l, long long r, long long x) { if (r >= l) { long long mid = l + (r - l) / 2; if (arr[mid] == x) return mid; if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); if (arr[mid] < x) return binarySearch(...
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 MOD = 1e18; const long long N = 2e5 + 5; long long a[N]; int main() { long long i, j, k, l; long long n, m, t; cin >> n >> k; long long minx = MOD, ans = 0; for (i = 0; i < n; i++) scanf("%lld", &a[i]), minx = min(minx, a[i]); for (i = 0; i < 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 ...
def main(): n, s = map(int, input().split()) a = list(map(int, input().split())) if sum(a) < s: return -1 if len(set(a)) != 1: a.sort(reverse = True) q = a[-1] for i in range(n): s -= (a[i] - q) if s <= 0: return q if s % 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 java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class Keggs { public static void main(String args[]) throws NumberFormatException, IOException { long n; long k; Scanner sc = new Scanner(new ...
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 ...
#526_B import sys import math s = int(sys.stdin.readline().rstrip().split(" ")[1]) lne = [int(i) for i in sys.stdin.readline().rstrip().split(" ")] n = min(math.floor((sum(lne) - s) / len(lne)), min(lne)) if n >= 0: print(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 ...
n,s = [int(i) for i in input().split()] v = [int(i) for i in input().split()] v = sorted(v) sv = sum(v) if s > sv: print(-1) else: for i in v: s-= (i-v[0]) if s<= 0: print(v[0]) else: print((n*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 ...
import java.io.*; public class new4 { public static void main(String args[])throws IOException { BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); String str1=br.readLine(); long n=Long.parseLong(str1.substring(0,str1.indexOf(' '))); long s=Long.parseLong(str1.substring(str1.indexOf...
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; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author Andy Phan */ public class p001084b { public static void 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 ...
# Author: Harrison Whitner # Date: 02/13/19 # get the first line of input, which contains the number of kegs and size of glass n, s = list(map(int, input().split())) # get the next line which contains the keg amounts kegs = list(map(int, input().split())) # print -1 if there is not enough kvass if sum(kegs) < s: 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.StringTokenizer; import java.util.TreeMap; import java.util.TreeSet; public class Today { public static void main(String[] args) throws IOException, InterruptedException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); ...
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: print(-1) exit(0) mv = min(v) for i in range(n): s -= v[i] - mv if s < 1: print(mv) exit(0) ans = mv - s // n if s % n != 0: ans -= 1 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 ...
n, s = map(int, input().split()) A = list(map(int, input().split())) mn = 1e18 res = 0 for i in A : mn = min(i, mn) res += i if res < s : print(-1) elif s < res - mn*n : print(mn) else : s = s - (res - mn*n) print(mn - (s + 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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n; long long s, sum = 0; cin >> n >> s; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } if (sum < s) { cout << -1; return 0; } long long c = 0; sort(a, a + n); if (n == 1) { cout << a[0] - 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> using namespace std; template <typename T> ostream& operator<<(ostream& os, vector<T>&& object) { for (auto& i : object) { os << i; } return os; } template <typename T> ostream& operator<<(ostream& os, vector<vector<T>>&& object) { for (auto& i : object) { os << i << endl; } ...
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 ...
""""""""""""""""""""""""""""""""""""""""""""" | author: mr.math - Hakimov Rahimjon | | e-mail: mr.math0777@gmail.com | """"""""""""""""""""""""""""""""""""""""""""" #inp = open("lepus.in", "r"); input = inp.readline; out = open("lepus.out", "w"); print = out.write TN = 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 _mp(): return map(int,raw_input().split()) n,s=_mp() a=_mp() tot=sum(a) if tot<s: print -1 else: z=min(a) left=tot-z*n if left>s: print z else: left=s-left k=left/n if left%n==0: print z-k else: print z-k-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 n, s, a[1010], sum, mim = 0x3f3f3f3f, l, r, mid, ans = 0; int can(long long x) { return (sum - n * x >= s ? 1 : 0); } int main() { cin >> n >> s; for (int i = 1; i <= n; i++) { cin >> a[i]; sum += a[i]; mim = min(mim, 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 ...
import java.util.*; import java.io.*; // Solution public class Main { public static void main (String[] argv) { new Main(); } boolean test = false; final int MOD = 998244353; public Main() { FastReader in = new FastReader(new BufferedReader(new InputStreamRead...
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; public class B { public static void main(String[] args) throws NumberFormatException, IOException { Scanner sc = new Scanner(); PrintWriter out = new PrintWri...
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, a[1005], s, mini, tot; int main() { cin >> n >> s; tot = 0; mini = 1e15; for (int i = 1; i <= n; i++) { cin >> a[i]; tot += a[i]; mini = min(a[i], mini); } if (tot < s) { cout << -1; return 0; } tot = tot - s; mini = min(to...
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 static java.lang.Math.*; public class Main { static final long MOD = 1_000_000_007, INF = 1_000_000_000_000_000_000L; static final int INf = 1_000_000_000; static FastReader reader; static PrintWriter writer; 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 ...
#include <bits/stdc++.h> const int N = 1e7 + 2 + 5, M = 1e3 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 7; int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}; int dy[] = {1, -1, 0, 0, -1, 1, 1, -1}; int dxx[] = {-1, 1, -1, 1, -2, -2, 2, 2}; int dyy[] = {-2, -2, 2, 2, 1, -1, 1, -1}; using namespace std; long long gcd(long long x, long long y...
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 ...
# alpha = "abcdefghijklmnopqrstuvwxyz" from heapq import heappop, heappush t = 1#int(input()) for test in range(t): n,s = (map(int, input().split())) a = list(map(int, input().split())) if sum(a)<s: print(-1) continue heap = [] for i in range(n): heappush(heap, (-a[i],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 sys n, s = [int(s) for s in input().split()] array = [int(s) for s in input().split()] sorted_array = sorted(array) min_ = sorted_array[0] if sum(array) < s: print(-1) sys.exit(0) if sum(array) == s: print(0) sys.exit(0) if sum(array) - n * min_ >= s: print(min_) else: print(min_ - ((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> using namespace std; const long long MOD = 1e9 + 7; const long long SIZE = 100000; const int INF = 0x3f3f3f3f; const long long ll_INF = 0x3f3f3f3f3f3f3f3f; const long double PI = acos(-1); const long long MAXN = numeric_limits<long long>::max(); const long long MAX = 2000000; void disp(vector<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 ...
import java.util.Scanner; import java.util.HashMap; import java.util.Stack; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.lang.StringBuilder; public class idk { static Scanner scn = new Scanner(System.in); public static void main(String[] args) { // TODO Auto-gener...
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 foo(s,v): n = len(v) if sum(v) < s: return -1 mini = min(v) for i in range(n): s -= (v[i]-mini) if s <= 0: return mini #now common level is mini k = s//n s -= n*(k) mini -= k while s > 0: s -= n mini -= 1 return mini n,s = list(map(int,input().strip().split(" "))) v = list(map(int,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 ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; long long n, v, k; int main() { cin >> n >> k; long long mi = 0x3f3f3f3f, sum = 0; for (int i = 1; i <= n; i++) { cin >> v; mi = min(mi, v); sum += v; } if (sum < k) printf("-1\n"); else { sum -= k; printf("%I64...
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 ...
R=lambda:map(int,input().split()) n,s=R() v=[*R()] m=min(v) s=max(0,s-sum(v)+n*m) print(max(-1,m+-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; #pragma GCC optimize("O2") vector<long long int> ar[1000001]; long long int vis[1000001], dis[1000001], level[1000001]; const int MAX_SIZE = 1000001; const int N = 2000010; const int mod = 1e9 + 7; vector<int> isprime(MAX_SIZE, true); vector<int> prime; vector<int> SPF(MAX_...
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.math.BigInteger; import java.io.*; public class Codeforces{ static class MyScanner{ BufferedReader br; StringTokenizer st; MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } MyScanner(FileReader fileReader){ br = new BufferedReader(fileRea...
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.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class CF { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out...
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 ans(a,n,s): total = (sum(a) - s) m = min(a) if total < 0: return -1 if total//n > m: return m return total//n n,s = map(int,raw_input().split()) arr = [int(i) for i in raw_input().split()] print(ans(arr,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 ...
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Scanner; im...
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 ...
if __name__ == "__main__": n,s=map(int, input().split()) ls=list(map(int, input().split())) m=sum(ls)-min(ls)*n if s<=m: print(min(ls)) elif s>sum(ls): print("-1") else: print((sum(ls)-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() { long long n, s, val; cin >> n >> s; vector<long long> vec; long long sumtot = 0; for (long long i = 0; i < n; i++) { cin >> val; sumtot += val; vec.push_back(val); } if (sumtot < s) { cout << -1; return 0; } sort(vec.begin(...
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 ...
''' Thruth can only be found at one place - THE CODE ''' ''' Copyright 2018, SATYAM KUMAR''' from sys import stdin, stdout import cProfile, math from collections import Counter from bisect import bisect_left,bisect,bisect_right import itertools from copy import deepcopy from fractions import Fraction import sys, threa...
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 vk18 { public static void main(String[]st) { Scanner scan=new Scanner(System.in); int n,i; long sum=0,k; n=scan.nextInt(); k=scan.nextLong(); long a[]=new long[n]; for(i=0;i<n;i++) { 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; int main() { ios_base::sync_with_stdio; cin.tie(NULL); cout.tie(NULL); long long int i, j, sum = 0, n, m, min = 1000000001, ans, s; cin >> n >> s; long long int a[n]; for (i = 0; i < n; i++) { cin >> j; sum = sum + j; if (j <= min) min = j; } 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.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; import javafx.util.*; public class Solution { static class com implements Comparator<Pair<Integer,Integer>>{ public int compare(Pair<Integer,Integer...
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(0), cin.tie(0), cout.tie(0); long long int n = 0, k = 0, sum = 0; cin >> n >> k; long long int arr[n]; for (int a = 0; a < n; a++) cin >> arr[a]; sort(arr, arr + n); for (int a = 0; a < n; a++) sum += arr[a] - arr[0]; c...
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() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); size_t n; int64_t s; std::cin >> n >> s; std::vector<int64_t> v(n); for (size_t i = 0; i < n; ++i) { std::cin >> v[i]; } const int64_t min = *min_element(v.begin(), v.end()); int64_t cur = 0; for (si...
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 java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Ideone { public static void main (String[] args) throws java.lang.Exception { // your code goes here BufferedReader br=new BufferedReader (new InputStreamReader(System.in))...