結果

問題 No.1478 Simple Sugoroku
ユーザー 👑 jupirojupiro
提出日時 2021-04-16 22:24:02
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,309 bytes
コンパイル時間 1,043 ms
コンパイル使用メモリ 117,708 KB
実行使用メモリ 5,356 KB
最終ジャッジ日時 2023-09-16 01:14:42
合計ジャッジ時間 3,343 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 16 ms
5,356 KB
testcase_14 AC 15 ms
5,356 KB
testcase_15 AC 16 ms
4,928 KB
testcase_16 AC 16 ms
4,908 KB
testcase_17 AC 16 ms
4,864 KB
testcase_18 AC 16 ms
4,744 KB
testcase_19 AC 16 ms
4,812 KB
testcase_20 AC 16 ms
4,876 KB
testcase_21 AC 16 ms
5,288 KB
testcase_22 AC 16 ms
4,816 KB
testcase_23 AC 16 ms
4,908 KB
testcase_24 AC 16 ms
4,868 KB
testcase_25 AC 16 ms
4,932 KB
testcase_26 AC 16 ms
4,892 KB
testcase_27 AC 16 ms
4,884 KB
testcase_28 AC 13 ms
4,800 KB
testcase_29 AC 13 ms
4,788 KB
testcase_30 AC 13 ms
4,824 KB
testcase_31 AC 14 ms
4,820 KB
testcase_32 AC 13 ms
4,824 KB
testcase_33 AC 14 ms
4,720 KB
testcase_34 AC 15 ms
4,876 KB
testcase_35 AC 14 ms
5,312 KB
testcase_36 AC 15 ms
4,724 KB
testcase_37 AC 15 ms
5,288 KB
testcase_38 AC 15 ms
5,324 KB
testcase_39 AC 15 ms
4,876 KB
testcase_40 AC 15 ms
4,880 KB
権限があれば一括ダウンロードができます

ソースコード

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;
}
0