結果
| 問題 |
No.1478 Simple Sugoroku
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-16 21:13:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 55 ms / 2,000 ms |
| コード長 | 1,491 bytes |
| コンパイル時間 | 3,228 ms |
| コンパイル使用メモリ | 171,624 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-03 00:20:27 |
| 合計ジャッジ時間 | 5,794 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <atcoder/all>
#include <bitset>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using namespace atcoder;
//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//
void input() {
}
void solve() {
int N, M; cin >> N >> M;
vector<long double> B(M);
for(int i = 0; i < M; i++) {
int b; cin >> b;
B[M-i-1] = N-b;
}
long double ok = 0, ng = N;
long double Es = 0;
vector<long double> E(M);
int roop = 100;
while(roop--) {
long double mn = (ok + ng) / 2;
E.resize(M, 0);
E[0] = min(B[0], mn + 1);
Es = E[0];
for(int i = 1; i < M; i++) {
E[i] = min(B[i] - B[i-1] + E[i-1], mn + 1);
Es += E[i];
}
Es /= (long double)M;
Es > mn ? ok = mn : ng = mn;
}
long double ans = N - 1 - B[M-1] + E[M-1];
cout << fixed << setprecision(6);
cout << ans << endl;
}
//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//
int main() {
std::ifstream in("input.txt");
std::cin.rdbuf(in.rdbuf());
std::cin.tie(0);
ios::sync_with_stdio(false);
input();
solve();
return 0;
}