結果

問題 No.1478 Simple Sugoroku
ユーザー oteraotera
提出日時 2021-03-06 02:05:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 1,189 bytes
コンパイル時間 2,431 ms
コンパイル使用メモリ 197,032 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 17:39:52
合計ジャッジ時間 5,024 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 16 ms
5,376 KB
testcase_14 AC 15 ms
5,376 KB
testcase_15 AC 16 ms
5,376 KB
testcase_16 AC 18 ms
5,376 KB
testcase_17 AC 16 ms
5,376 KB
testcase_18 AC 16 ms
5,376 KB
testcase_19 AC 16 ms
5,376 KB
testcase_20 AC 16 ms
5,376 KB
testcase_21 AC 16 ms
5,376 KB
testcase_22 AC 17 ms
5,376 KB
testcase_23 AC 16 ms
5,376 KB
testcase_24 AC 16 ms
5,376 KB
testcase_25 AC 16 ms
5,376 KB
testcase_26 AC 16 ms
5,376 KB
testcase_27 AC 16 ms
5,376 KB
testcase_28 AC 12 ms
5,376 KB
testcase_29 AC 13 ms
5,376 KB
testcase_30 AC 13 ms
5,376 KB
testcase_31 AC 13 ms
5,376 KB
testcase_32 AC 13 ms
5,376 KB
testcase_33 AC 14 ms
5,376 KB
testcase_34 AC 14 ms
5,376 KB
testcase_35 AC 14 ms
5,376 KB
testcase_36 AC 14 ms
5,376 KB
testcase_37 AC 15 ms
5,376 KB
testcase_38 AC 15 ms
5,376 KB
testcase_39 AC 15 ms
5,376 KB
testcase_40 AC 15 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *    author:  otera
 *    created: 06.03.2021 01:14:21 
**/
#include<bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
    int n, m; cin >> n >> m;
    vector<ll> b(m);
    vector<ll> sum(m + 1, 0);
    for(int i = 0; i < m; ++ i) {
        cin >> b[i];
    }
    for(int i = 0; i < m; ++ i) {
        sum[i + 1] = sum[i] + (b[m - 1] - b[m - 1 - i]);
    }
    ld ans = (ld)(n - 1);
    int ok = m - 1, ng = 0;
    auto check = [&](int x) -> bool {
        int right = b[m - 1] - b[x];
        ld left = ((ld)m + (ld)sum[m - x]) / (ld)(m - x);
        if((ld)left >= (ld)right) return true;
        else return false;
    };
    while(ok - ng > 1) {
        int mid = (ok + ng) / 2;
        if(check(mid)) ok = mid;
        else ng = mid;
    }
    ld q = ((ld)m + (ld)sum[m - ok]) / (ld)(m - ok);
    chmin(ans, (ld)(n - b[m - 1] + b[0] - 1) + q);
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    // INT(t); rep(i, t)solve();
    solve();
    return 0;
}
0