Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
32877 LYLAKIOI 【S】T4 C++ 运行超时 81 2074 MS 4996 KB 1515 2024-10-02 13:51:20

Tests(56/57):


#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define pi pair<int,int> #define p1 first #define p2 second #define p_b push_back #define m_p make_pair using namespace std; typedef long long ll; const int maxn=2e5+10; inline ll read(){ ll x=0;short t=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; } mt19937 rng(0); int n,a[maxn]; vector<int>v[maxn]; int P[maxn],Q[maxn],vis[maxn]; bool cmp(int x,int y){ return a[x]<a[y]; } double calc(){ up(i,1,n)P[i]=Q[i],vis[i]=0; up(i,1,10){ int x=rng()%n+1,y=rng()%n+1; swap(P[x],P[y]); }double res=0; ll s1=0,s2=0; up(i,1,n){ int x=P[i]; s1+=a[x],s2+=a[x]*a[x];vis[x]=1; bool ok=0; up(j,1,i)for(int x:v[P[j]])if(!vis[x])ok=1; if(!ok)res=max(res,s1*s1*1.0/s2); }return res; } void slv(){ n=read();int m=read(); up(i,1,n)a[i]=read(); while(m--){ int x=read(),y=read(); v[x].p_b(y); }up(i,1,n)Q[i]=i;sort(Q+1,Q+n+1,cmp); int tim=200000/(max(1,n/10)+1);double res=0; while(tim--)res=max(res,calc()); printf("%.10lf",res); }int main(){ //freopen("sale.in","r",stdin); //freopen("sale.out","w",stdout); slv(); //cerr<<clock()*1.0/CLOCKS_PER_SEC<<"s\n"; fclose(stdin); fclose(stdout); return 0; }


测评信息: