Accepted
Code
#include<bits/stdc++.h>
using namespace std;
const long long M=1e7+1,MOD=1000000007;
typedef long long ll;
#define double long double
#define debug(x) cout<<x<<endl
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin>>t;
while(t--)
{
int n;
ll s;
cin>>n>>s;
vector<ll>v(n);
for(auto &i:v)cin>>i;
ll l=1,r=1e12;
ll answer=-1;
while(l<=r)
{
ll mid=l+(r-l)/2;
ll sum=0;
for(auto it:v)
{
sum+=(it/mid);
}
if(sum==s)
{
answer=mid;
r=mid-1;
}
else if(sum>s)l=mid+1;
else r=mid-1;
}
cout<<answer<<"\n";
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1057 Floor Sum
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-05-23 00:02:19
- Judged At
- 2024-11-11 03:29:43
- Judged By
- Score
- 100
- Total Time
- 304ms
- Peak Memory
- 2.812 MiB