結果
| 問題 |
No.110 しましまピラミッド
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-12-23 23:31:59 |
| 言語 | Python2 (2.7.18) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 5,000 ms |
| コード長 | 870 bytes |
| コンパイル時間 | 313 ms |
| コンパイル使用メモリ | 7,040 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-31 11:00:05 |
| 合計ジャッジ時間 | 1,651 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#!/usr/bin/env python
def read():
input()
wList = map(int, raw_input().split())
input()
bList = map(int, raw_input().split())
return wList, bList
def work((wList, bList)):
lengColorList = [] # (leng, isWhite)
for leng in wList:
lengColorList.append((leng, True))
for leng in bList:
lengColorList.append((leng, False))
lengColorList.sort()
# dp[lastColor][lastLeng]: best height
dp = [[-1 for j in range(21)] for i in range(2)]
dp[0][0] = 0
dp[1][0] = 0
for (leng, isWhite) in lengColorList:
for lastLeng in range(leng):
if dp[not isWhite][lastLeng] == -1:
continue
dp[isWhite][leng] = max(dp[isWhite][leng], dp[not isWhite][lastLeng] + 1)
print max(max(dp[0]), max(dp[1]))
if __name__ == "__main__":
work(read())