結果

問題 No.1478 Simple Sugoroku
ユーザー jupiro
提出日時 2021-04-16 22:24:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,309 bytes
コンパイル時間 1,179 ms
コンパイル使用メモリ 114,908 KB
最終ジャッジ日時 2025-01-20 20:08:44
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <tuple>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <array>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
using ll = long long;
using std::cin;
using std::cout;
using std::endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;
void solve()
{
int n, m; cin >> n >> m;
std::vector<int> b(m);
for (int i = 0; i < m; ++i)
{
cin >> b[i];
}
using real = long double;
std::vector<real> dp(m);
dp.back() = n - b.back();
real sum = dp.back();
for (int i = m - 2; i >= 0; --i)
{
real pr = (real)(m - i - 1) / (real)m;
dp[i] = std::min<real>((1 + sum / (real)m) / pr, n - b[i]);
sum += dp[i];
}
real res = 1e18;
for (int i = 0; i < m; ++i)
{
chmin(res, dp[i] + b[i] - 1);
}
cout << std::fixed << std::setprecision(15) << res << "\n";
}
int main()
{
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
int kkt = 1;
//cin >> kkt;
while(kkt--)
solve();
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0