description stringlengths 35 9.39k | solution stringlengths 7 465k |
|---|---|
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import sys
input=sys.stdin.readline
n,q=list(map(int,input().split()))
s=list(input())
a=[0]
b=0
for i in range(n):
b=b+int(s[i])
a.append(b)
mod=10**9+7
for i in range(q):
b,c=list(map(int,input().split()))
d=a[c]-a[b-1]
e=c-b+1-d
f=(pow(2,d,mod)-1)*pow(2,e,mod)
print((f)%mod) |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1, mod = 1e9 + 7;
int n, q;
long long arr[N];
long long pref[N];
long long binpow(long long a, long long s) {
long long ans = 1;
while (s) {
if (s & 1) {
ans *= a;
ans %= mod;
}
a *= a;
a %= mod;
s >>= 1;
}
return ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
long long n, q, sum[100004], mod = 1e9 + 7;
string s;
long long get_sum(long long i, long long j) {
if (i == 0) return sum[j];
return sum[j] - sum[i - 1];
}
long long expo(long long v, long long e) {
if (v == 0) return 0;
if (e == 0) return 1;
if (e == 1) return v... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
const long long mod = 1e9 + 7;
using namespace std;
long long a[100005] = {0};
string str;
long long quickpow(long long a, long long n) {
long long ans = 1;
long long tmp = a % mod;
while (n) {
if (n & 1) {
ans = ((ans) % mod * (tmp) % mod) % mod;
}
tmp = ((tmp % mod) * ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
int n, q, cnt[100005];
long long ans, x, y;
char s[100005];
long long pow(long long a, long long x) {
long long b = 1;
while (x > 0) {
if (x % 2) b = (b * a) % 1000000007;
x = x / 2;
a = (a * a) % 1000000007;
}
return b;
}
int main() {
int i, l, r;
s... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import configparser
import math
import sys
input = sys.stdin.readline
def mod_exp(base, exp, mod):
# cur_iter = base^(2^0)) = base^1 = base
cur_iter = base
cur_iter %= mod
result = 1
while exp > 0:
if (1 & exp) > 0:
result = result * cur_iter
result %= mod
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long mod2 = 998244353;
long long mod3 = 1000003;
long long mod4 = 998244853;
long long mod5 = 1000000009;
long long inf = 1LL << 62;
double pi = 3.141592653589793238462643383279L;
double eps = 1e-14;
int dh[4] = {1, -1, 0, 0};
int dw[4] = {0... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int MOD = 1000000007;
int N, Q;
char c[MAXN];
int S[MAXN];
long long modpow(long long base, long long expo) {
base %= MOD;
long long res = 1;
while (expo > 0) {
if (expo & 1) res = res * base % MOD;
base = base * base % MOD;
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.util.*;
public class Main{
public static int MOD=1000000007;
public static long[] powers;
public static long solve(int[] a,int x,int y){
int ones=a[y]-a[x-1],zeros=y-x+1-ones;
long onesum=powers[ones]-1;
long zerosum=(onesum*(powers[zeros]))%MOD;
return zerosum;
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.io.*;
import java.util.*;
public class C {
public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
public static void main(String[] args) throws IOException {
readInput();
out.clo... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.lang.*;
import java.util.*;
import java.io.*;
public class CF1335{
static long power(long x, long y, long p)
{
long res = 1;
x = x % p;
if (x == 0) return 0;
while (y > 0)
{
if((y & 1)==1)
res = (res * x) % p; ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
int n, q, x, y, z, h;
string s;
long long a[100005], b[100005];
void init() {
b[0] = 1;
for (long long(i) = (1); (i) <= (n); ++(i)) b[i] = b[i - 1] * 2 % 1000000007;
}
int main() {
cin >> n >> q;
cin >> s;
init();
for (long long(i) = (0); (i) < (n); ++(i)) a[i] ... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import sys
input = sys.stdin.readline
mod = 10**9+7
n,q = map(int,input().split())
t= input()
zero=[0]*(n)
ones=[0]*(n)
if t[0]=='0':
zero[0]=1
else:
ones[0]=1
for j in range(1,n):
if t[j]=='0':
zero[j]=zero[j-1]+1
ones[j]=ones[j-1]
else:
ones[j]= ones[j-1]+1
... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... |
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.InputMismatchException;
/**
* @author thesparkboy
*
*/
public class A3 {
static int[] bit;
static int n, MOD = (int) 1e9 + 7;
static void update(int idx, int... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import java.util.*;
import java.io.*;
public class Banhmi {
/************************ SOLUTION STARTS HERE ************************/
static class MM { // MM (Modular Math) class
static final long mod = (long) (1e9) + 7; // Default
static long sub(long a, long b) {retu... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | #include <bits/stdc++.h>
using namespace std;
int n, a[100005];
string s;
long long fastpow(int a, int b) {
if (b == 0) return 1LL;
if (b == 1) return 1LL * a;
int tmp = fastpow(a, b / 2) * fastpow(a, b / 2) % 1000000007;
if (b % 2 == 1)
return tmp * a % 1000000007;
else
return tmp;
}
int main() {
i... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | from sys import *
m = 1000000007
n, q = map(int, stdin.readline().split())
a = stdin.readline()
ans = []
t = []
count = 0
for i in a:
if i == '1':
count+=1
t.append(count)
for _ in range(q):
x,y=map(int,input().split())
if(x==1):
p=t[y-1]
else:
p=t[y-1]-t[x-2]
q=(y-x+1-p)
s=pow(2,p+q,m) - (pow(2,q,m))
a... |
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into n parts, places them on a row and numbers them from 1 through n. For each part i, he de... | import sys
r = sys.stdin.readlines()
M = 10 ** 9 + 7
twopow = [1] * 100001
for j in range(1, 100001):
twopow[j] = (twopow[j - 1] * 2) % M
n, q = r[0].split(' ')
n = int(n)
q = int(q)
s = r[1]
p = [0]
for v in range(n):
p.append(p[v] + int(s[v]))
ans = []
for k in range(q):
a, b = r[k + 2].split(' ')
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;
long long n, a[1001], cnt = 0;
long long s;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> s;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
sort(a + 1, a + n + 1);
for (int i = 2; i <= n; i++) {
cnt += a[i] - a[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.util.*;
public class Solution
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
int n=in.nextInt();
long s,min=999999999,sum=0,t=0;
s=in.nextLong();
long v[]=new long[n];
for(int i=0;i<n;i++)
{
v[i]=in.nextLong();
if(min>v[i])
min=v[i];
t+=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;
int main() {
long long int n, a;
cin >> n >> a;
long long int arra[n + 1];
long long int sum = 0;
for (int i = 0; i < n; i++) {
cin >> arra[i];
sum = sum + arra[i];
}
if (sum >= a) {
long long int val = 0;
sort(arra, arra + n);
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;
void q1() {
long long int n;
cin >> n;
long long int arr[n];
long long int maxi = 0;
for (long long int i = 0; i < n; i++) {
cin >> arr[i];
if (arr[i] >= arr[maxi]) maxi = i;
}
maxi = 0;
long long int total = 0;
for (long long int i = 0; i < n; 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 ... | x,y=map(int,input().split())
s=list(map(int,input().split()))
if sum(s)<y:
print(-1)
else:
j=sum(s)-y
if j<x:
print(0)
elif x==j:
print(1)
else:
print(min(min(s),j//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 ... | n,m=map(int,input().split())
l=list(map(int,input().split()))
su=sum(l)
if su<m :
print(-1)
else :
c=(su-m)//n
print(min(min(l),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 ... | n, s = map(int, input().split())
a = list(map(int, input().split()))
def check(x):
global s
tot = 0
for i in a:
tot += i - x
return tot >= s
sum = 0
mi = 1e9
for i in a:
sum += i
mi = min(mi, i)
if sum < s:
print(-1)
else:
l = 0
r = mi
ans = r
while r >= 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;
long long n, minn = 1e18;
long long a[1010];
int main() {
long long n, s, sum = 0;
cin >> n >> s;
for (long long i = 1; i <= n; ++i)
cin >> a[i], minn = min(minn, a[i]), sum += a[i];
if (s <= sum - n * minn) {
cout << minn << endl;
return 0;
}
if (mi... |
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;
import java.util.StringTokenizer;
import java.util.*;
public class CodeForces {
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 math
n, s = map(int, input().split())
l = list(map(int, input().split()))
t1 = sum(l)
if t1<s:
print('-1')
else:
m = min(l)
t2 = 0
for i in range(len(l)):
x = l[i]-m
t2 = t2 + x
if t2 > s:
print(m)
else:
y = s - t2
ts = math.ceil(y/len(l))
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,s=map(int,input().split())
a=list(map(int,input().split()))
y=min(a)*n
x=sum(a)
if x<s:
print(-1)
else:
if s<=x-y:
print(y//n)
else:
s=s-(x-y)
print((y-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.*;
import java.util.*;
public class B_KvassAndTheFairNut {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader inp = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStr... |
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,req=map(int,input().split())
ar=[int(x) for x in input().split()]
given=0
minn=min(ar)
for k in range(n):
given+=ar[k]-minn
if req-given>n*minn:
print(-1)
elif req-given<=0:
print(minn)
else:
print(minn-ceil((req-given)/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 doit():
xx = input().split()
n = int(xx[0])
s = int(xx[1])
v = [int(k) for k in input().split()]
S = sum(v)
newS = S - s
if newS < 0:
return -1
return min(newS//n, min(v))
print(doit())
|
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)
else:
mi = min(v)
num = 0
for i in range(N):
num += v[i] - mi
v[i] -= v[i] - mi
if s - num <= 0:
print(mi)
else:
m = (s - num) // N + int((s - num) % N != 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 ... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, s;
cin >> n >> s;
vector<long long int> v(n);
long long int pp = 1e18;
long long int cnt = 0;
long long int kk = 0;
for (int i = 0; i < n; i++) {
cin >> v[i];
pp = min(pp, v[i]);
kk += v[i];
}
for (int 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 ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author real
*/
public class Main ... |
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 A671{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long k=sc.nextLong();
long[] ar=new long[n];
long sum=0;
for(int i=0;i<n;i++){
ar[i]=sc.nextLong()... |
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);
cin.tie(0);
long long n, s;
cin >> n >> s;
vector<long long> v(n);
long long base = 0x3f3f3f3f3f3f3f3f;
long long tot = 0;
for (auto &i : v) {
cin >> i;
base = min(base, i);
tot += i;
}
if (tot < s) retur... |
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 cf {
static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner(Reader in) {
br = new BufferedReader(in);
}
public FastScanner() {
this(new InputStreamReade... |
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 double EPS = 0.0000000001;
const long long mod1 = 998244353;
const long long mod2 = 1000000007;
const long long mod3 = 1000000009;
const long long inf = 1000000000000000000;
signed main() {
long long n, a;
cin >> n >> a;
long long mass[n];
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 ... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 12 19:13:40 2018
@author: mach
"""
n,m = map(int, input().strip().split())
l = list(map(int, input().strip().split()))
a_s = sum(l)
if a_s < m :
print(-1)
else:
l.sort(reverse=True)
mins = l[n-1]
for i in range(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 abso(long long x) { return x > 0 ? x : (-x); }
signed main() {
long long n, s;
scanf("%lld%lld", &n, &s);
vector<long long> v;
v.resize(n);
long long sum = 0;
for (long long i = 0; i < n; i++) {
scanf("%lld", &v[i]);
sum += 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 java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Spoj {
public static void main(String[] arg) {
final Scanner scanner = new Scanner(System.in);
long n = scanner.nextLong();
long s = scanner.nextLong();
long[] arr = new long[(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 ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.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;
int n, v[1005];
long long g, sum = 0;
int main() {
cin >> n >> g;
for (int i = 1; i <= n; i++) cin >> v[i];
sort(v + 1, v + n + 1, greater<int>());
for (int i = 1; i <= n; i++) sum += v[i];
if (sum < g) {
cout << -1;
return 0;
}
for (int i = 1; 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 ... | import math
n, s = list(map(int, input().split()))
v = list(map(int, input().split()))
sum_v = sum(v)
if sum_v < s:
print(-1)
else:
v.sort()
minimum = v[0]
remaining = s - (sum_v - n * minimum)
if remaining <= 0:
print(minimum)
else:
print(minimum - int(math.ceil(remaining/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 = [int(x) for x in input().split()]
v.sort()
l = v[0]
for i in range(1,n):
if v[i]>l:
s -= v[i]-l
if s <= 0:
print(v[0])
else:
r = (s+n-1)//n
if r > v[0]:
print(-1)
else:
print(v[0]-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;
long long int 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)
cout << -1;
else if (t - m * n < s)
cout << (t - s) / n;
else
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.*;
public class div400{
public static void main(String sp[]){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long s = sc.nextLong();
ArrayList<Integer> al = new ArrayList<>();
for(int i=0;i<n;i++)
al.add(sc.nextInt());
long total=0;
for(int i=0;i<n;i++)
total+=al.get... |
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 INF64 = 1e18 + 1337;
const int INF32 = 1e9 + 228;
const int MOD = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, s;
cin >> n >> s;
vector<long long> a(n);
long long sum = 0;
for (int i = 0; i < n; 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 n, m, a[1000001], check(0), sum(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
sort(a + 1, a + n + 1);
for (int i = n; i >= 1; i--) {
check += a[i] - a[1];
}
if (m > sum)
cout << -1;
els... |
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
nmbr=lambda:int(stdin.readline())
lst=lambda:list(map(int, stdin.readline().split()))
def fn(fin):
sm=0
for v in a:
if v>=fin:sm+=v-fin
else:return False
return sm>=req
for _ in range(1):#nmbr()):
n,req=lst()
a=lst()
if sum(a)<req:
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=map(int,input().split())
v=sorted(list(map(int,input().split())))
if sum(v)<s:
print(-1)
else:
s0=sum(v)-v[0]*n
if s<=s0:
print(v[0])
else:
s-=s0
if s%n==0:
print(v[0]-s//n)
else:
print(v[0]-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,s = map(int,input().split())
a = list(map(int,input().split()))
if sum(a) < s: print(-1)
elif sum(a) == s: print(0)
else:
ans = 0
for i in range(n):
if a[i] != min(a): ans += (a[i]-min(a)); a[i] = min(a)
print(min(min(a),min(a)-((s-ans)//n)-((s-ans)%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 ... | n, s = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]
if sum(a) < s:
print(-1)
else:
a.sort()
s -= sum(a) - a[0] * n
if (s < 1):
print(a[0])
elif s % n == 0:
print(a[0] - s//n)
else:
print(a[0] - (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 ... | m,n = input().split(' ')
m = int(m)
n = int(n)
s = list(map(int,input().split(' ')))
t = 0
for i in s:
t += i
t = t-n
t = t // m
less = 10**9+1
for i in s:
if i < less:
less = i
if t < 0:
print(-1)
else:
if less < t:
print(less)
else:
print(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 ... |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long s=sc.nextLong();
long min=Integer.MAX_VALUE;
long sum=0;
for(int i=0;i<n;i++) {
long x=sc.nextLong();
min=Math.min(x, min);
sum+=x;
}
// System.o... |
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;
using ll = long long;
ll V[1001];
int main() {
ll n, s;
cin >> n >> s;
ll mmin = 0;
ll sum = 0;
for (ll i = 1; i <= n; i++) {
cin >> V[i];
sum += V[i];
mmin = mmin == 0 ? V[i] : (min(V[i], mmin));
}
ll t = 0;
for (ll i = 1; i <= n; i++) t += abs(... |
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
import bisect
def solve(A, m):
n = len(A)
if sum(A) < m:
return -1
min_val = min(A)
tmp = sum(A) - min_val * n
if tmp >= m:
return min_val
m -= tmp
ans = (min_val * n - m) // n
return ans
def main():
n, m = map(int, input().split())
A = li... |
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(NULL);
long long int n, s, arr[1010] = {0}, c = 0, m = 1000000001;
cin >> n >> s;
for (int i = 0; i < n; i++) {
cin >> arr[i];
c += arr[i];
m = min(m, arr[i]);
}
long long int sur = 0;
for (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;
long long n, s;
long long v[1001];
bool f(long long x) {
long long sum = 0;
for (int i = 0; i < n; i++) {
sum += v[i] - x;
}
if (sum >= s) return true;
return false;
}
int main() {
cin >> n >> s;
long long mn = 10e9 + 1, sum = 0;
for (int i = 0; i < n; 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.*;
import java.lang.*;
import java.math.*;
public final class Main{
public static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
try {
br = new BufferedReader(new InputStreamReader(System.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 ... |
n,k=map(int,input().split())
l=list(map(int,input().split()))
m=min(l)
s=sum(l)
if sum(l)<k:
print(-1)
elif s-m*n>=k:
print(m)
else:
val=s-m*n
k-=val
print(m-(k//n+int(k%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 ... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n, s;
cin >> n >> s;
ll ar[n];
ll su = 0;
for (int i = 0; i < n; i++) {
cin >> ar[i];
su += ar[i];
}
if (su < s) {
cout << -1 << "\n";
} else {
sort(ar, ar + n);
ll dif = 0;
for (int i = 1; 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 ... | #include <bits/stdc++.h>
using namespace std;
int main(void) {
long long n, val;
cin >> n >> val;
vector<long long> v(n);
long long minV = LLONG_MAX;
long long ts = 0;
for (long long i = 0; i < n; i++) {
cin >> v[i];
minV = min(minV, v[i]);
ts += v[i];
}
long long bufSpace = 0;
for (long 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=input().split()
n=int(n)
s=int(s)
l=input().split()
l=list(map(int,l))
x=sum(l)
m=min(l)
h=len(l)
if x<s:
print(-1)
elif m*h<=(x-s):
print(m)
else:
q=(m*h-(x-s))/h
if int(q)==q:
print(m-int(q))
else:
print(m-(int(q)+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.*;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;
public class l {
public static void main(String[]args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(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 ... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, s, sum = 0;
cin >> n >> s;
long long a[n];
int i;
for (i = 0; i < n; ++i) {
cin >> a[i];
if (sum <= s + 1) {
sum += a[i];
}
}
if (sum == s) {
cout << 0 << endl;
} else if (sum < s) {
cout << -1 << 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 ... | n, s = [int(w) for w in input().split()]
v = [int(w) for w in input().split()]
r = sum(v) - s
if r < 0:
print(-1)
else:
print(min(r // n, *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 ... | def _1084B():
n, s = map(int, input().split())
aa = list(map(int, input().split()))
mn = min(aa)
if sum(aa) < s:
return -1
totdif = 0
for i in range(n):
totdif += aa[i]-mn
if s <= totdif:
return mn
s -= totdif
q, r = s//n, s%n
return mn-q if r == 0 else 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,s = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
l.reverse()
k = min(l)
x = 0
if s > sum(l):
print(-1)
exit()
for i in range(len(l)):
if l[i] > k:
s -= l[i] - k
l[i] = k
if s > 0:
if s % len(l) != 0:
tt = s // len(l)
tt += 1
else:
tt = s // len(l)
s -= tt * len(l)
l[0] -= tt
p... |
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.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Random;
import java.util.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>
inline void read(T& x) {
int f = 0, c = getchar();
x = 0;
while (!isdigit(c)) f |= c == '-', c = getchar();
while (isdigit(c)) x = x * 10 + c - 48, c = getchar();
if (f) x = -x;
}
template <typename T, typename... Args>
inline void read(T& 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 ... | import java.util.*;
import java.io.*;
import java.lang.*;
public class fair{
public static void main(String[] arg) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
StringToken... |
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), v = map(int, input().split()), tuple(map(int, input().split()))
minv, sumv = min(v), sum(v)
maxminv = (sumv - s) // n
# print(n, s, sumv, minv, maxminv)
print(-1 if s > sumv else (minv if minv < maxminv else maxminv))
|
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 codeforces.contests.round526;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* @author tainic on Nov 28, 2018
*/
public class B {
//private static final boolean LOCAL = "aurel".equ... |
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())
l=map(int,raw_input().split())
l.sort()
su=sum(l)
if su<s:
print -1
else:
deff=su-s
mini=deff/n
print min(mini,l[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 = list(map(int,input().split()))
arr = list(map(int,input().split()))
if sum(arr)<s:
print(-1)
else:
arr.sort()
now = 0
minn = arr[0]
for i in range(len(arr)-1,0,-1):
if now>=s:
break
else:
now += arr[i]-minn
rem = s - now
if rem<=0:
prin... |
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;
cin >> n >> s;
long long sum = 0;
long long a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
}
if (sum < s) {
cout << -1;
return 0;
}
sort(a, a + n);
for (int i = n - 1; i >= 1; i--) {
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 java.util.Scanner;
public class Task1 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
long s=in.nextLong();
long minkol=1000000000;
long v=-s;
for (int i = 0; i <n ; i++) {
int a=in.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 ... | import java.io.*;
import java.util.*;
public class Main{
static int mod = (int)(Math.pow(10, 9) + 7);
public static void main(String[] args) {
MyScanner sc = new MyScanner();
out = new PrintWriter(new BufferedOutputStream(System.out));
int n = sc.nextInt();
long s = sc.nextLong();
... |
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.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
public class z1 {
public static void main(String[] args) {
BigInteger k;
int n;
Scanner in = new Scanner(System.in);
n = in.nextInt();
k = in.nextBigInteger();
BigInteger[] m = new BigInt... |
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 =[]
cap = 0
def chck (k):
ans=0
for i in arr:
if (i<k):
return False
ans=ans+i-k
if (ans>=cap):
return True
return False
def bsrch (strt,ed):
ans=-1
while (strt<=ed):
mid=(strt+ed)//2
if (chck(mid)):
ans=mid
strt=mid... |
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 mynfn():
x=input().split(" ")
n=int(x[0])
s=int(x[1])
y=input().split(" ")
min=1000000000000
sum=0
k=0
for i in range(len(y)):
y[i]=int(y[i])
if y[i]<min:
min=y[i]
k=i
sum=sum+y[i]
if sum<s:
print("-1")
else:
a=sum-min*n
if a>=s:
print(min)
else:
h1=int((s-a)/n)
h2=(s-a)%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;
using ll = long long;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll t;
t = 1;
while (t--) {
ll n, k;
cin >> n >> k;
ll a[n], m = INT_MAX, sum = 0, j = 0;
for (ll i = 0; i < n; i++) {
cin >> a[i];
m = min(m, 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 Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner ip=new Scanner(System.in);
long n=ip.nextLong();
long k=ip.nextLong();
long a[]=new long[1000+5];
long mn=1000000000+5;
long all=0;
for(int i=0;i<n;i++){
a[i]=ip.nextL... |
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 ... | /* package whatever; // don't place package name! */
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
{
Scanner sc=new Scanner(System.in);
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 ... | import java.util.Scanner;
public class Main {
final static int INF = 0x3f3f3f3f;
static long n, s;
static int[] a = new int[1100];
public static boolean check(int m) {
long sum = 0;
for(int i = 0; i < n; i++) {
sum += a[i]-m;
}
return sum >= s;
}
public static void main(String[] args) {
Scanner ... |
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()
v.sort()
a=v[0]
for i in range(n):
s-=v[i]-a
if s<=0:
print(a)
else:
b=a-1-((s-1)//n)
if b>0:
print(b)
else:
print(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().split())
v = [int(i) for i in input().split()]
minVol = min(v)
sumVol = 0
for i in range(0,n):
sumVol = sumVol+v[i]
if sumVol < s :
print (-1)
elif sumVol == s:
print(0)
else:
kvas = 0
for i in range(n):
if v[i] > minVol:
kvas = kvas + v[i] - minVol
... |
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];
int main() {
long long n, s;
cin >> n >> s;
int Min = INT_MAX;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (a[i] < Min) Min = a[i];
}
long long sum = 0;
for (int i = 1; i <= n; i++) {
sum += (a[i] - Min);
}
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 ... | n,s=map(int,input().split(' '))
a=list(map(int,input().split(' ')))
a.sort()
h=sum(a)
if h>s:
min=a[0]
f=h-min*n
if f>=s:
print(min)
else:
print((h-s)//n)
elif h==s:
print(0)
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 ... | I=lambda: map(int,input().split())
n, s=I()
l=list(I())
x=min(l)
total=0
for i in range(n):
total+=(l[i]-x)
y=s-total
if y<=0:
print(x)
else:
z=y//n
a=y%n
if a==0:
x=x-z
else:
z=z+1
x=x-z
if x<0:
print(-1)
else:
print(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 main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
long long S;
cin >> S;
vector<long long> a(n);
long long sum = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i];
sum += a[i];
}
if (sum < S) {
cout << -1;
return 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;
int main() {
long long int n, s, i, an = 0, x;
cin >> n >> s;
int a[n];
for (i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
for (i = 1; i < n; i++) an += (a[i] - a[0]);
if (an >= s)
cout << a[0];
else {
s -= an;
x = a[0];
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 ... | import java.util.Scanner;
public class kegs {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
double s=sc.nextDouble();
double[] k=new double[n];
for(int i=0;i<n;i++) {
k[i]=sc.nextDouble();
}
int pos=findLeast(k);
double level=findUsed(k,pos);
if(level... |
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
a, b = input().split()
a, b = int(a), int(b)
k = input().split()
kk = k[:]
k = []
sum = 0
for i in kk:
a = int(i)
sum += a
k.append(a)
if sum < b:
print(-1)
sys.exit()
k.sort()
least = k[0]
summ = sum - least * len(k)
k = [least for i in k]
if(summ >= b):
print(least)
sys.ex... |
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.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.Arrays;
import java.util.InputMismatchException;
/**
* @author thesparkboy
*
*/
public class A2 {
public static void main(String[] args) {
InputReader in = ne... |
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, count = 0, k, t = 0, p, i, j;
cin >> n >> s;
long long int a[n];
for (i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
}
if (sum < s)
cout << "-1";
else {
sort(a, a + n);
p = 0;
k = a[0];
for ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.