結果

問題 No.1478 Simple Sugoroku
ユーザー nok0nok0
提出日時 2021-03-02 15:56:45
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 771 bytes
コンパイル時間 8,175 ms
コンパイル使用メモリ 322,156 KB
実行使用メモリ 9,944 KB
最終ジャッジ日時 2024-04-14 04:41:15
合計ジャッジ時間 10,489 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,948 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 29 ms
9,436 KB
testcase_14 AC 28 ms
9,056 KB
testcase_15 AC 29 ms
8,796 KB
testcase_16 AC 29 ms
9,696 KB
testcase_17 AC 29 ms
8,408 KB
testcase_18 AC 29 ms
8,416 KB
testcase_19 AC 29 ms
8,540 KB
testcase_20 AC 30 ms
8,920 KB
testcase_21 AC 29 ms
9,696 KB
testcase_22 AC 29 ms
8,284 KB
testcase_23 AC 30 ms
8,540 KB
testcase_24 AC 29 ms
8,284 KB
testcase_25 AC 29 ms
9,308 KB
testcase_26 AC 29 ms
8,284 KB
testcase_27 AC 30 ms
8,536 KB
testcase_28 AC 21 ms
8,028 KB
testcase_29 AC 23 ms
9,944 KB
testcase_30 AC 23 ms
8,668 KB
testcase_31 AC 23 ms
8,032 KB
testcase_32 AC 23 ms
9,692 KB
testcase_33 AC 25 ms
8,408 KB
testcase_34 AC 26 ms
8,280 KB
testcase_35 AC 26 ms
9,176 KB
testcase_36 AC 26 ms
9,052 KB
testcase_37 AC 27 ms
8,412 KB
testcase_38 AC 28 ms
8,924 KB
testcase_39 AC 27 ms
8,412 KB
testcase_40 AC 28 ms
8,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include "testlib.h"
using namespace std;

int n, m;
long double res = 1e18;
long double cost;
long long base;
int main() {
	registerValidation();
	int n = inf.readInt(1, 1000000000);
	inf.readSpace();
	int m = inf.readInt(1, min(n, 100000));
	inf.readEoln();
	vector<int> b(m);
	int bef = 0;
	for(int i = 0; i < m; i++) {
		if(i) inf.readSpace();
		b[i] = inf.readInt(bef + 1, n);
		bef = b[i];
	}
	inf.readEoln();
	inf.readEof();
	if(m <= 1) {
		printf("%d\n", n - 1);
		return 0;
	}
	base += b.front() - 1 + n - b.back();
	res = b.back() - b.front();
	for(int i = m - 1; i >= 1; i--) {
		cost += b.back() - b[i];
		res = min(res, cost / (m - i) + (long double)m / (m - i));
	}
	cout << fixed << setprecision(6);
	cout << res + base << endl;
}
0