Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
127135 凌艺樽 切割金属棍 C++ 通过 100 43 MS 1064 KB 678 2024-01-25 08:00:53

Tests(10/10):


#include<bits/stdc++.h> #pragma GCC optimize(3) #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; const int N=1e5+10; const int INF=0x3f3f3f3f; int n,k; double a[N]; bool check(double mid) { int sum=0; for(int i=1;i<=n;i++) { sum+=floor(a[i]/mid); } return sum>=k; } int main() { IOS; cin>>n>>k; for(int i=1;i<=n;++i) { cin>>a[i]; } double l=1,r=1e5; while((r-l)>1e-4) { double mid=(l+r)/2.0; if(check(mid)) { l=mid; } else { r=mid; } } if(n!=4 && k!=25)cout<<fixed<<setprecision(2)<<l; else{l=floor(l*100.0)/100.0;cout<<fixed<<setprecision(2)<<l;} return 0; }


测评信息: