結果

問題 No.706 多眼生物の調査
ユーザー バカらっくバカらっく
提出日時 2018-07-01 01:59:05
言語 Swift
(5.10.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 734 bytes
コンパイル時間 4,827 ms
コンパイル使用メモリ 130,792 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2023-08-20 10:49:54
合計ジャッジ時間 6,627 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,616 KB
testcase_01 AC 4 ms
7,516 KB
testcase_02 AC 3 ms
7,616 KB
testcase_03 AC 4 ms
7,576 KB
testcase_04 AC 6 ms
7,464 KB
testcase_05 AC 18 ms
7,720 KB
testcase_06 AC 41 ms
7,852 KB
testcase_07 AC 4 ms
7,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class Main {
    
    func Proc() {
        let inputCount = Int(readLine()!)!
        var dic = [Int:Int]()
        var cntMax = 0
        var ans = 0
        for _ in 0..<inputCount {
            let inpt = readLine()!.map{ $0 }.filter{ $0 == "^" }.count
            if let num = dic[inpt] {
                dic[inpt] = num + 1
            } else {
                dic[inpt] = 1
            }
            if dic[inpt]! == cntMax {
                if ans < inpt {
                    ans = inpt
                    cntMax = dic[inpt]!
                }
            } else if dic[inpt]! > cntMax {
                ans = inpt
                cntMax = dic[inpt]!
            }
        }
        print(ans)
    }
    
}


Main().Proc()
0