結果
問題 |
No.110 しましまピラミッド
|
ユーザー |
![]() |
提出日時 | 2018-06-11 17:22:54 |
言語 | Swift (6.0.3) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,206 bytes |
コンパイル時間 | 1,292 ms |
コンパイル使用メモリ | 135,796 KB |
実行使用メモリ | 19,072 KB |
最終ジャッジ日時 | 2024-11-30 12:32:00 |
合計ジャッジ時間 | 122,318 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 TLE * 2 |
other | AC * 9 TLE * 17 |
ソースコード
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()