結果
問題 | No.9008 空白区切りで与えられる数値データの合計値を求める(テスト用) |
ユーザー | shoichiro-sasaki |
提出日時 | 2018-04-28 19:22:05 |
言語 | OCaml (5.1.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,241 bytes |
コンパイル時間 | 417 ms |
コンパイル使用メモリ | 21,708 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-09 00:30:20 |
合計ジャッジ時間 | 1,312 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
ソースコード
open Scanf open Printf let ($) f x = f x let scanIntlist n = let list = ref [] in for i = 1 to n do list := (scanf (if i < n then "%d " else "%d") (fun x -> x))::!list done; List.rev !list let string2charlist s = let rec proc i res = try proc (i+1) $ s.[i]::res with Invalid_argument _ -> res in List.rev $ proc 0 [] let minInt l = let rec proc l res = match l with [] -> res | x::xs -> if x < res then proc xs x else proc xs res in if l == [] then raise $ Failure "null list" else proc l max_int let maxInt l = let rec proc l res = match l with [] -> res | x::xs -> if x > res then proc xs x else proc xs res in if l == [] then raise $ Failure "null list" else proc l min_int let rec listSum = function [] -> 0 | x::xs -> x+listSum xs;; let rec quick_sort = function ([] | [_]) as l -> l | pivot :: rest -> let rec partition left right = function [] -> (quick_sort left) @ (pivot :: quick_sort right) | y :: ys -> if pivot < y then partition left (y :: right) ys else partition (y :: left) right ys in partition [] [] rest;; scanf "%d" $ fun n -> print_int ( listSum (scanIntlist n));;