結果
問題 | No.1478 Simple Sugoroku |
ユーザー |
![]() |
提出日時 | 2021-04-16 22:32:47 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 226 ms / 2,000 ms |
コード長 | 803 bytes |
コンパイル時間 | 3,470 ms |
コンパイル使用メモリ | 77,224 KB |
実行使用メモリ | 49,748 KB |
最終ジャッジ日時 | 2024-07-03 02:40:42 |
合計ジャッジ時間 | 10,917 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
import java.io.BufferedReader;import java.io.InputStreamReader;public class Main {public static void main(String[] args) throws Exception {BufferedReader br = new BufferedReader(new InputStreamReader(System.in));String[] sa = br.readLine().split(" ");int n = Integer.parseInt(sa[0]);int m = Integer.parseInt(sa[1]);sa = br.readLine().split(" ");int[] b = new int[m];for (int i = 0; i < m; i++) {b[i] = Integer.parseInt(sa[i]);}br.close();double e = b[m - 1] - b[0];long sum = 0;int cnt = 0;for (int i = m - 1; i >= 0; i--) {int d = b[m - 1] - b[i];sum += d;cnt++;double e1 = (double) m / cnt;double e2 = (double) sum / cnt;e = Math.min(e, e1 + e2);}double ans = b[0] - 1 + e + n - b[m - 1];System.out.println(ans);}}