百度无人车
样例
样例输入1
4
6 7 8 9
1 3
样例输出1
7
样例输入2
5
11 14 6 13 11
4 68
样例输出2
8
题意
直接二分就行了, 爆LL,,,
AC代码
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
#define ls st<<1
#define rs st<<1|1
#define fst first
#define snd second
#define MP make_pair
#define PB push_back
#define LL long long
#define PII pair<int,int>
#define VI vector<int>
#define CLR(a,b) memset(a, (b), sizeof(a))
#define ALL(x) x.begin(),x.end()
#define ber(i,s,e) for(int i=(s); i<=(e); i++)
#define rep(i,s,e) for(int i=(s); i>=(e); i--)
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5+10;
const int mod = 1e9+7;
const double eps = 1e-8;
void fe() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt","w",stdout);
#endif
}
LL read()
{
LL x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
return x*f;
}
LL arr[MAXN];
LL n, p, s;
bool check(int x) {
LL sum = 0;
for(int i = 0; i < n; i++) {
sum += max(0LL,arr[i]-x);
}
return sum*p <= s;
}
int main() {
ios::sync_with_stdio(false);
cin >> n;
for(int i = 0; i < n; i++)
cin >> arr[i];
cin >> p >> s;
LL l = 1, r = 2e4;
LL mid;
while(r >= l) {
mid = l+(r-l)/2;
if(check(mid))
r = mid-1;
else
l = mid+1;
}
if(check(r+1)) r++;
cout << r << endl;
return 0;
}