結果

問題 No.349 干支の置き物
コンテスト
ユーザー バカらっく
提出日時 2018-03-02 17:16:23
言語 Swift
(6.4)
コンパイル:
swiftc _filename_ -Ounchecked -o a.out
実行:
./a.out
結果
WA  
実行時間 -
コード長 320 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 559 ms
コンパイル使用メモリ 144,628 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2026-10-02 14:26:17
合計ジャッジ時間 2,559 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.swift:6:5: warning: immutable value 'i' was never used; consider replacing with '_' or removing it [#no-usage]
 4 | 
 5 | var mx = 0
 6 | for i in 0..<itemCount {
   |     `- warning: immutable value 'i' was never used; consider replacing with '_' or removing it [#no-usage]
 7 |     let nm = readLine()!
 8 |     if(dic[nm] == nil) {

ソースコード

diff #
raw source code

let itemCount = Int(readLine()!)!

var dic = [String:Int]()

var mx = 0
for i in 0..<itemCount {
    let nm = readLine()!
    if(dic[nm] == nil) {
        dic[nm] = 1
    } else {
        dic[nm] = dic[nm]! + 1
    }
    mx = max(mx, dic[nm]!)
}

if(mx > itemCount / 2) {
    print("NO")    
} else {
    print("YES")
}
0