提出 #60991544


ソースコード 拡げる

#include <bits/stdc++.h>
#define ll long long
#define pii pair <ll, ll>
using namespace std;
const int N = 4e5 + 10;
ll x[N], h[N];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int n; cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> x[i] >> h[i];
	if (n == 1) {
		cout << "0.00000000";
		return 0;
	}
	long double ans = -1e18;
	ll ansfz = 0, ansfm = 0;
	priority_queue <pii> q;
	for (int i = 1; i <= n; ++i) {
		if (i != 1) {
			while (!q.empty()) {
				ll tmp = q.top().first;
				ll pos = q.top().second; q.pop();
				ll now_fz = h[pos] * (x[pos] - x[i]) - x[pos] * (h[pos] - h[i]);
				ll now_fm = x[pos] - x[i];
				if (ansfm == 0 || now_fz * ansfm > ansfz * now_fm) {
					ansfz = now_fz, ansfm = now_fm; 
					if (q.top().first != tmp) break;
				}
			}
		}
		q.push({h[i], i});
	}
	ans = ansfz * 1.0 / ansfm;
	if (ans < 0) {
		cout << "-1";
		return 0;
	}
	if (ans == 0) {
		cout << "0.000000000000000000000000";
		return 0;
	}
	cout << fixed << setprecision(20) << ans;
	// Why : Wa 1 ????
	return 0;
}

提出情報

提出日時
問題 F - Visible Buildings
ユーザ C2026zhaoyl
言語 C++ 20 (gcc 12.2)
得点 0
コード長 1093 Byte
結果 WA
実行時間 23 ms
メモリ 6864 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 525
結果
AC × 4
AC × 26
WA × 1
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 1 ms 3624 KiB
hand_02.txt AC 1 ms 3528 KiB
hand_03.txt AC 1 ms 3732 KiB
hand_04.txt WA 1 ms 3432 KiB
random_01.txt AC 23 ms 6864 KiB
random_02.txt AC 17 ms 5868 KiB
random_03.txt AC 16 ms 5648 KiB
random_04.txt AC 8 ms 4772 KiB
random_05.txt AC 18 ms 6036 KiB
random_06.txt AC 9 ms 5012 KiB
random_07.txt AC 4 ms 4068 KiB
random_08.txt AC 13 ms 5104 KiB
random_09.txt AC 3 ms 3908 KiB
random_10.txt AC 6 ms 4324 KiB
random_11.txt AC 16 ms 5844 KiB
random_12.txt AC 11 ms 5136 KiB
random_13.txt AC 3 ms 3692 KiB
random_14.txt AC 6 ms 4140 KiB
random_15.txt AC 19 ms 5772 KiB
random_16.txt AC 17 ms 5744 KiB
random_17.txt AC 12 ms 5176 KiB
random_18.txt AC 17 ms 5996 KiB
random_19.txt AC 13 ms 5500 KiB
sample_01.txt AC 1 ms 3740 KiB
sample_02.txt AC 1 ms 3432 KiB
sample_03.txt AC 1 ms 3320 KiB
sample_04.txt AC 1 ms 3692 KiB