Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
32419 22级廖思学 【S】T2 C++ 运行出错 16 66 MS 292 KB 846 2024-09-08 16:59:06

Tests(4/25):


#include<bits/stdc++.h> using namespace std; #define int long long const int M=2e5+10,mmax=1e10; int n,m,L,ed[M]; bool check(int mid){ int sum=0; for(int i=1;i<=m;i++){ if(ed[i]<mid)sum+=mid-ed[i]; } return sum<=L; } signed main(){ //freopen("wildfire.in","r",stdin); //freopen("wildfire.out","w",stdout); int id,t;cin>>id>>t; while(t--){ cin>>n>>m>>L; assert(m==n-1); if(m==n-1){ int u,v,l=mmax,r; for(int i=1;i<=m;i++){cin>>u>>v>>ed[i];l=min(l,ed[i]);} if(L==0){cout<<l<<endl;continue;} l=1,r=10000000000ll; while(l<r){ int mid=(l+r+1)>>1; if(check(mid))l=mid; else r=mid-1; } cout<<l<<endl; } } return 0; }


测评信息: