提交时间:2022-07-20 11:58:32
运行 ID: 52798
#include <bits/stdc++.h> using namespace std; inline int read() { int x=0; char c=getchar(); for(; c<'0' || c>'9'; c=getchar()); for(; c<='9' && c>='0'; c=getchar()) x=(x<<3)+(x<<1)+c-'0'; return x; } int main() { int n,a,b; n=read(),a=read(),b=read(); int an[n+1]; for(int i=1; i<=n; i++) { an[i]=read(); } double ans1= 1; for(int i=2; i<=n; i++) { ans1*=i; } ans1*=b; double ans2=0; for(int i=1; i<=n; i++) { int min=an[i],minn=i; for(int j=i+1; j<=n; j++) { if(an[j]<min) { min=an[j]; minn=j; } } if(an[i]>min) { swap(an[i],an[minn]); ans2+=a; } } printf("%.9lf",min(ans1,ans2)); return 0; }