結果
問題 | No.929 よくあるボールを移動するやつ |
ユーザー |
|
提出日時 | 2019-11-23 06:13:26 |
言語 | OCaml (5.2.1) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 400 bytes |
コンパイル時間 | 544 ms |
コンパイル使用メモリ | 21,576 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-09 00:50:59 |
合計ジャッジ時間 | 1,250 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 |
ソースコード
open Scanf ;;open Printf ;;let input_int () = scanf " %d" (fun x -> x) ;;let input_ints n = Array.init n (fun _ -> input_int ()) ;;let () =let n = input_int () inlet b = input_ints n inlet rec loop i s ans =if i = n then anselse beginlet s' = s + b.(i) inlet ans' = ans + abs (i - s) inloop (i + 1) s' ans'endinprintf "%d\n" (loop 0 0 0);;