結果
問題 | No.110 しましまピラミッド |
ユーザー |
![]() |
提出日時 | 2018-06-11 17:24:02 |
言語 | Swift (6.0.3) |
結果 |
AC
|
実行時間 | 8 ms / 5,000 ms |
コード長 | 1,208 bytes |
コンパイル時間 | 1,479 ms |
コンパイル使用メモリ | 135,448 KB |
実行使用メモリ | 9,344 KB |
最終ジャッジ日時 | 2024-11-30 12:29:40 |
合計ジャッジ時間 | 2,482 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
class Proc { let blackBlock:[Int] let whiteBlock:[Int] init() { _ = readLine()! self.whiteBlock = readLine()!.split(separator: " ").map{ Int($0)!}.sorted() _ = readLine()! self.blackBlock = readLine()!.split(separator: " ").map{ Int($0)! }.sorted() } public func doProc() { var ans = GetAns(idx: blackBlock.count - 1, isBlack: true) ans = max(ans, GetAns(idx: whiteBlock.count-1, isBlack: false)) print(ans) } private func GetAns(idx:Int, isBlack:Bool) -> Int { let currentLen = isBlack ? self.blackBlock[idx] : self.whiteBlock[idx] var next = -1 if isBlack { for i in 0..<whiteBlock.count { if whiteBlock[i] >= currentLen { break } next = i } } else { for i in 0..<blackBlock.count { if blackBlock[i] >= currentLen { break } next = i } } if next < 0 { return 1 } let ans = GetAns(idx: next, isBlack: !isBlack) + 1 return ans } } Proc().doProc()