提出 #39673091


ソースコード 拡げる

#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
#ifdef DEBUG
	freopen("1.in", "r", stdin);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a, b;
	for(int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		if(x > 0) {
			a.eb(x);
		}
		else {
			b.eb(x);
		}
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	vector<int> c;
	for(int i = 0; i < (int)a.size(); i++) {
		if(i + 1 <= 3 || (int)a.size() - i <= 3) {
			c.eb(a[i]);
		}
	}
	for(int i = 0; i < (int)b.size(); i++) {
		if(i + 1 <= 3 || (int)b.size() - i <= 3) {
			c.eb(b[i]);
		}
	}
	ld mx = -1e18, mn = 1e18;
	for(int i = 0; i < (int)c.size(); i++) {
		for(int j = i + 1; j < (int)c.size(); j++) {
			for(int k = j + 1; k < (int)c.size(); k++) {
				ld x = (ld)(c[i] + c[j] + c[k]) / (1ll * c[i] * c[j] * c[k]);
				mn = min(mn, x);
				mx = max(mx, x);
			}
		}
	}
	cout << fixed << setprecision(12) << mn << '\n' << mx << '\n';
	return 0;
}

提出情報

提出日時
問題 B - Sum-Product Ratio
ユーザ yanchengzhi
言語 C++ (GCC 9.2.1)
得点 500
コード長 1146 Byte
結果 AC
実行時間 39 ms
メモリ 4368 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 3
AC × 48
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
01_sample_01.txt AC 8 ms 3656 KiB
01_sample_02.txt AC 2 ms 3716 KiB
01_sample_03.txt AC 2 ms 3696 KiB
02_small_01.txt AC 2 ms 3752 KiB
02_small_02.txt AC 2 ms 3820 KiB
02_small_03.txt AC 2 ms 3820 KiB
02_small_04.txt AC 2 ms 3680 KiB
02_small_05.txt AC 2 ms 3712 KiB
02_small_06.txt AC 2 ms 3656 KiB
02_small_07.txt AC 2 ms 3752 KiB
02_small_08.txt AC 2 ms 3820 KiB
02_small_09.txt AC 2 ms 3748 KiB
02_small_10.txt AC 2 ms 3820 KiB
02_small_11.txt AC 2 ms 3716 KiB
02_small_12.txt AC 3 ms 3748 KiB
02_small_13.txt AC 2 ms 3656 KiB
02_small_14.txt AC 2 ms 3672 KiB
02_small_15.txt AC 2 ms 3680 KiB
02_small_16.txt AC 2 ms 3656 KiB
03_rand_1_01.txt AC 32 ms 4196 KiB
03_rand_1_02.txt AC 33 ms 4292 KiB
03_rand_1_03.txt AC 34 ms 4204 KiB
03_rand_1_04.txt AC 32 ms 4240 KiB
03_rand_1_05.txt AC 37 ms 4316 KiB
04_rand_2_01.txt AC 35 ms 4116 KiB
04_rand_2_02.txt AC 36 ms 4232 KiB
04_rand_2_03.txt AC 38 ms 4144 KiB
04_rand_2_04.txt AC 36 ms 4312 KiB
04_rand_2_05.txt AC 36 ms 4368 KiB
05_almost_negative_01.txt AC 36 ms 4108 KiB
05_almost_negative_02.txt AC 39 ms 4256 KiB
05_almost_negative_03.txt AC 36 ms 4224 KiB
05_almost_negative_04.txt AC 36 ms 4088 KiB
05_almost_negative_05.txt AC 35 ms 4060 KiB
05_almost_negative_06.txt AC 34 ms 4176 KiB
05_almost_negative_07.txt AC 36 ms 4216 KiB
05_almost_negative_08.txt AC 37 ms 4284 KiB
06_almost_positive_01.txt AC 38 ms 4176 KiB
06_almost_positive_02.txt AC 34 ms 4248 KiB
06_almost_positive_03.txt AC 35 ms 4220 KiB
06_almost_positive_04.txt AC 34 ms 4272 KiB
06_almost_positive_05.txt AC 34 ms 4216 KiB
06_almost_positive_06.txt AC 36 ms 4252 KiB
06_almost_positive_07.txt AC 34 ms 4088 KiB
06_almost_positive_08.txt AC 34 ms 4220 KiB
07_many_equal_01.txt AC 27 ms 4168 KiB
07_many_equal_02.txt AC 23 ms 4224 KiB
07_many_equal_03.txt AC 27 ms 4232 KiB