結果

問題 No.706 多眼生物の調査
ユーザー MaboyMaboy
提出日時 2021-06-21 21:28:43
言語 Swift
(5.10.0)
結果
AC  
実行時間 658 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 2,386 ms
コンパイル使用メモリ 180,548 KB
実行使用メモリ 14,784 KB
最終ジャッジ日時 2023-09-05 01:56:06
合計ジャッジ時間 4,089 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
14,784 KB
testcase_01 AC 7 ms
14,664 KB
testcase_02 AC 7 ms
14,120 KB
testcase_03 AC 17 ms
14,680 KB
testcase_04 AC 56 ms
14,376 KB
testcase_05 AC 246 ms
14,532 KB
testcase_06 AC 658 ms
14,612 KB
testcase_07 AC 6 ms
14,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import Foundation
let n = Int(readLine()!)!
var l = [Int]()
for _ in 1...n{
    let s = readLine()!
    l += [s.count - s.replacingOccurrences(of: "^", with: "").count]
}
var d = [Int:Int]()
let s = Set(l)

for i in s{
    var c = 0
    for j in l{
        c += i == j ? 1 : 0
    }
    d[i] = c
}
var k = 0
var v = 0
for i in d{
    if i.value > v{
        v = i.value
        k = i.key
    }else if i.value == v{
        if i.key > k{
            k = i.key
        }
    }
}
print(k)
0