結果

問題 No.135 とりあえず1次元の問題
ユーザー バカらっくバカらっく
提出日時 2018-02-18 15:54:32
言語 Swift
(5.10.0)
結果
WA  
実行時間 -
コード長 609 bytes
コンパイル時間 1,681 ms
コンパイル使用メモリ 137,612 KB
実行使用メモリ 9,344 KB
最終ジャッジ日時 2024-05-07 17:13:31
合計ジャッジ時間 2,620 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 8 ms
9,216 KB
testcase_03 WA -
testcase_04 AC 7 ms
9,216 KB
testcase_05 AC 8 ms
9,216 KB
testcase_06 AC 7 ms
9,216 KB
testcase_07 AC 7 ms
9,216 KB
testcase_08 AC 7 ms
9,216 KB
testcase_09 AC 7 ms
9,088 KB
testcase_10 AC 8 ms
9,216 KB
testcase_11 AC 7 ms
9,216 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 7 ms
9,088 KB
testcase_15 WA -
testcase_16 AC 7 ms
9,344 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 8 ms
9,088 KB
testcase_21 WA -
testcase_22 AC 6 ms
9,216 KB
evil01.txt WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.swift:4:9: warning: variable 'initStr' was never mutated; consider changing to 'let' constant
    var initStr:[String] = [
    ~~~ ^
    let

ソースコード

diff #

//: Playground - noun: a place where people can play

func makeReadLineMethod()->()->String? {
    var initStr:[String] = [
        "4",
        "0 1 1 0"
    ]
    var idx = -1;
    func proc()->String? {
        idx+=1
        return initStr[idx];
    }
    return proc;
}
var readLine = makeReadLineMethod();


let pointCount = Int(readLine()!);

let points = readLine()!.split(separator: " ").map({Int($0)!}).sorted(by: {$0<$1});

var ans = abs(points.first!-points.last!);

for i in 1...points.count-1 {
    let tmp = points[i]-points[i-1];
    if(tmp>0) {
        ans=min(ans, tmp);
    }
}
print(ans);
0