Submission #48230863
Source Code Expand
// LUOGU_RID: 138434138
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
#define rep(i,l,r) for(int i(l);i<=(r);++i)
#define per(i,r,l) for(int i(r);i>=(l);--i)
#define eb emplace_back
#define File(filename) freopen(filename ".in","r",stdin),freopen(filename ".out","w",stdout)
#ifdef EXODUS
#define Debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define Debug(...) 0
#endif
//=========================================================================================================
// Something about IO
template<typename T>
void read(T &x){
x=0;T flg=1;
char ch=getchar();
while(!isdigit(ch)){if(ch=='-')flg=-1;ch=getchar();}
while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
x*=flg;
}
template<typename T,typename... Args>
void read(T &x,Args &...args){read(x),read(args...);}
//=========================================================================================================
// Define the global variables here.
bool membg=0;
const int N=2e5+7;
int n;
int a[N];
bool memed=0;
//=========================================================================================================
// Code here.
void solve(){
read(n);
for(int i=1;i<=n;i++){read(a[i]);}
sort(a+1,a+n+1);
int pos=partition(a+1,a+n+1,[&](int x){return x<0;})-a;
// for(int i=1;i<=n;i++)Debug("%d ",a[i]);
// Debug("\n");
vector<int>lis;
// Debug("pos = %d\n",pos);
for(int i=1;i<pos&&i<=3;i++)lis.eb(i);
for(int i=pos-1;i>=1&&i>=pos-3;i--)lis.eb(i);
for(int i=pos;i<=n&&i<=pos+2;i++)lis.eb(i);
for(int i=n;i>=n-2&&i>=pos;i--)lis.eb(i);
sort(lis.begin(),lis.end());lis.erase(unique(lis.begin(),lis.end()),lis.end());
ldb mnans=1e18,mxans=-1e18;
for(auto x:lis)for(auto y:lis)for(auto z:lis){
if(x==y||y==z||z==x)continue;
// printf("%d %d %d\n",x,y,z);
ldb cur=(ldb)(a[x]+a[y]+a[z])/a[x]/a[y]/a[z];
mxans=max(mxans,cur);
mnans=min(mnans,cur);
}
printf("%.15Lf\n%.15Lf\n",mnans,mxans);
return;
}
//=========================================================================================================
int main(){
Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
int timbg=clock();
int T=1;
while(T--)solve();
int timed=clock();
Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
fflush(stdout);
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Sum-Product Ratio |
| User | EXODUS |
| Language | C++ 17 (gcc 12.2) |
| Score | 500 |
| Code Size | 2433 Byte |
| Status | AC |
| Exec Time | 18 ms |
| Memory | 4660 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:18:28: warning: statement has no effect [-Wunused-value]
18 | #define Debug(...) 0
| ^
Main.cpp:79:9: note: in expansion of macro ‘Debug’
79 | Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
| ^~~~~
Main.cpp:18:28: warning: statement has no effect [-Wunused-value]
18 | #define Debug(...) 0
| ^
Main.cpp:84:9: note: in expansion of macro ‘Debug’
84 | Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
| ^~~~~
Main.cpp:80:13: warning: unused variable ‘timbg’ [-Wunused-variable]
80 | int timbg=clock();
| ^~~~~
Main.cpp:83:13: warning: unused variable ‘timed’ [-Wunused-variable]
83 | int timed=clock();
| ^~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt |
| All | 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 02_small_06.txt, 02_small_07.txt, 02_small_08.txt, 02_small_09.txt, 02_small_10.txt, 02_small_11.txt, 02_small_12.txt, 02_small_13.txt, 02_small_14.txt, 02_small_15.txt, 02_small_16.txt, 03_rand_1_01.txt, 03_rand_1_02.txt, 03_rand_1_03.txt, 03_rand_1_04.txt, 03_rand_1_05.txt, 04_rand_2_01.txt, 04_rand_2_02.txt, 04_rand_2_03.txt, 04_rand_2_04.txt, 04_rand_2_05.txt, 05_almost_negative_01.txt, 05_almost_negative_02.txt, 05_almost_negative_03.txt, 05_almost_negative_04.txt, 05_almost_negative_05.txt, 05_almost_negative_06.txt, 05_almost_negative_07.txt, 05_almost_negative_08.txt, 06_almost_positive_01.txt, 06_almost_positive_02.txt, 06_almost_positive_03.txt, 06_almost_positive_04.txt, 06_almost_positive_05.txt, 06_almost_positive_06.txt, 06_almost_positive_07.txt, 06_almost_positive_08.txt, 07_many_equal_01.txt, 07_many_equal_02.txt, 07_many_equal_03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01_sample_01.txt | AC | 1 ms | 3672 KiB |
| 01_sample_02.txt | AC | 1 ms | 3628 KiB |
| 01_sample_03.txt | AC | 1 ms | 3724 KiB |
| 02_small_01.txt | AC | 1 ms | 3736 KiB |
| 02_small_02.txt | AC | 1 ms | 3836 KiB |
| 02_small_03.txt | AC | 1 ms | 3736 KiB |
| 02_small_04.txt | AC | 1 ms | 3768 KiB |
| 02_small_05.txt | AC | 1 ms | 3792 KiB |
| 02_small_06.txt | AC | 1 ms | 3728 KiB |
| 02_small_07.txt | AC | 1 ms | 3768 KiB |
| 02_small_08.txt | AC | 1 ms | 3780 KiB |
| 02_small_09.txt | AC | 1 ms | 3840 KiB |
| 02_small_10.txt | AC | 1 ms | 3784 KiB |
| 02_small_11.txt | AC | 1 ms | 3776 KiB |
| 02_small_12.txt | AC | 1 ms | 3880 KiB |
| 02_small_13.txt | AC | 1 ms | 3792 KiB |
| 02_small_14.txt | AC | 1 ms | 3772 KiB |
| 02_small_15.txt | AC | 1 ms | 3736 KiB |
| 02_small_16.txt | AC | 1 ms | 3740 KiB |
| 03_rand_1_01.txt | AC | 18 ms | 4508 KiB |
| 03_rand_1_02.txt | AC | 18 ms | 4660 KiB |
| 03_rand_1_03.txt | AC | 18 ms | 4564 KiB |
| 03_rand_1_04.txt | AC | 18 ms | 4616 KiB |
| 03_rand_1_05.txt | AC | 18 ms | 4556 KiB |
| 04_rand_2_01.txt | AC | 17 ms | 4500 KiB |
| 04_rand_2_02.txt | AC | 18 ms | 4620 KiB |
| 04_rand_2_03.txt | AC | 18 ms | 4544 KiB |
| 04_rand_2_04.txt | AC | 18 ms | 4568 KiB |
| 04_rand_2_05.txt | AC | 18 ms | 4564 KiB |
| 05_almost_negative_01.txt | AC | 17 ms | 4616 KiB |
| 05_almost_negative_02.txt | AC | 17 ms | 4560 KiB |
| 05_almost_negative_03.txt | AC | 17 ms | 4560 KiB |
| 05_almost_negative_04.txt | AC | 17 ms | 4480 KiB |
| 05_almost_negative_05.txt | AC | 17 ms | 4516 KiB |
| 05_almost_negative_06.txt | AC | 17 ms | 4448 KiB |
| 05_almost_negative_07.txt | AC | 17 ms | 4416 KiB |
| 05_almost_negative_08.txt | AC | 17 ms | 4564 KiB |
| 06_almost_positive_01.txt | AC | 17 ms | 4512 KiB |
| 06_almost_positive_02.txt | AC | 17 ms | 4568 KiB |
| 06_almost_positive_03.txt | AC | 17 ms | 4504 KiB |
| 06_almost_positive_04.txt | AC | 17 ms | 4552 KiB |
| 06_almost_positive_05.txt | AC | 17 ms | 4504 KiB |
| 06_almost_positive_06.txt | AC | 18 ms | 4508 KiB |
| 06_almost_positive_07.txt | AC | 17 ms | 4544 KiB |
| 06_almost_positive_08.txt | AC | 17 ms | 4560 KiB |
| 07_many_equal_01.txt | AC | 7 ms | 4444 KiB |
| 07_many_equal_02.txt | AC | 8 ms | 4476 KiB |
| 07_many_equal_03.txt | AC | 8 ms | 4540 KiB |