1 solutions
-
0
C++ :
#include<bits/stdc++.h> using namespace std; long long n,m,a[1000100],ma; //check函数 long long check(long long x){ long long ans = 0; for(int i = 1;i <= n;i++){ if(a[i] > x){ ans = ans + (a[i] - x); } } return ans; } int main(){ cin>>n>>m; for(int i = 1;i <= n;i++){ cin>>a[i]; ma = max(a[i],ma);//求最大 } long long l=1,r=ma,mid; while(l <= r){ mid = (l + r) >>1; if(check(mid) < m) r = mid-1; else l = mid + 1; } cout<<l-1; }
- 1
Information
- ID
- 9950
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By