結果

問題 No.1478 Simple Sugoroku
ユーザー 🍮かんプリン
提出日時 2021-04-16 22:28:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 975 bytes
コンパイル時間 1,385 ms
コンパイル使用メモリ 169,884 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-03 02:31:31
合計ジャッジ時間 4,358 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2021.04.16 22:27:32
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n,m;cin >> n >> m;
    vector<int> a(m);
    double plus = 0;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        if (i == 0) plus += a[i]-1;
        else if (i == m-1) plus += n-a[i];
    }
    double left = 0, right = 1000000000;
    double ans;
    int loop_cnt = 50;
    for (int t = 0; t < loop_cnt; t++) {
        double mid = (left+right)/2;
        vector<double> dp(m,0);
        double sum = 0;
        for (int i = m-2; i >= 0; i--) {
            dp[i] = min(dp[i+1]+a[i+1]-a[i],mid+1);
            sum += dp[i];
        }
        cout << mid << " " << sum/2 << endl;
        if (sum/m >= mid) {
            left = mid;
        }
        else {
            right = mid;
        }
        if (t == loop_cnt-1) ans = dp[0];
    }
    printf("%.10f\n",ans+plus);
    return 0;
}
0