結果
| 問題 | No.1416 ショッピングモール | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-06-02 07:17:50 | 
| 言語 | OCaml (5.2.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 998 bytes | 
| コンパイル時間 | 1,603 ms | 
| コンパイル使用メモリ | 19,824 KB | 
| 実行使用メモリ | 9,880 KB | 
| 最終ジャッジ日時 | 2024-11-14 05:02:24 | 
| 合計ジャッジ時間 | 2,639 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 WA * 2 | 
| other | WA * 21 | 
ソースコード
let split_on_char sep s =
  let r = ref [] in
  let j = ref (String.length s) in
  for i = String.length s - 1 downto 0 do
    if String.unsafe_get s i = sep then begin
      r := String.sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  String.sub s 0 !j :: !r;;
let pow x y =
  let rec inner_pow i result =
    match i with
    | 0 -> result
    | _ -> inner_pow (i - 1) (result * x) in
  inner_pow y 1;;
let rec shop_tumeru cost k hairu lst =
  match lst with
  | [] -> cost
  | _ ->
    let max_k = pow 2 k in
    if (hairu >= max_k) then shop_tumeru cost (k + 1) hairu lst
    else
      let next_shop = List.hd lst in
      let lst = List.tl lst in
      let cost = cost + (next_shop * k) in
      let hairu = hairu + 1 in
      shop_tumeru cost k hairu lst;;
let () =
  read_line () |> ignore;
  let lst = read_line () |> split_on_char ' ' |> List.map int_of_string |> List.fast_sort (fun x y -> - ( compare x y)) in
  shop_tumeru 0 0 0 lst |> print_int; print_newline ();;
            
            
            
        