結果

問題 No.1478 Simple Sugoroku
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2021-04-16 22:25:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 902 bytes
コンパイル時間 1,399 ms
コンパイル使用メモリ 168,512 KB
実行使用メモリ 4,540 KB
最終ジャッジ日時 2023-09-16 01:17:22
合計ジャッジ時間 4,783 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 54 ms
4,380 KB
testcase_30 AC 55 ms
4,476 KB
testcase_31 AC 54 ms
4,504 KB
testcase_32 AC 55 ms
4,444 KB
testcase_33 AC 57 ms
4,404 KB
testcase_34 AC 57 ms
4,452 KB
testcase_35 AC 57 ms
4,380 KB
testcase_36 AC 57 ms
4,396 KB
testcase_37 AC 60 ms
4,528 KB
testcase_38 AC 60 ms
4,396 KB
testcase_39 AC 60 ms
4,472 KB
testcase_40 AC 60 ms
4,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:39:11: 警告: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
   39 |     printf("%.10f\n",ans+plus);
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp:21:12: 備考: ‘ans’ はここで定義されています
   21 |     double ans;
      |            ^~~

ソースコード

diff #

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

#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;
    for (int t = 0; t < 50; 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];
        }
        
        if (sum/m >= mid) {
            left = mid;
        }
        else {
            right = mid;
        }
        if (t == 99) ans = dp[0];
    }
    printf("%.10f\n",ans+plus);
    return 0;
}
0