結果
問題 |
No.110 しましまピラミッド
|
ユーザー |
|
提出日時 | 2025-08-29 09:52:26 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 829 bytes |
コンパイル時間 | 3,220 ms |
コンパイル使用メモリ | 169,580 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-08-29 09:52:31 |
合計ジャッジ時間 | 4,821 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
module main; import std; void main() { // 入力 int NW = readln.chomp.to!int; auto W = readln.split.to!(int[]); int NB = readln.chomp.to!int; auto B = readln.split.to!(int[]); // 答えの計算 int ans = 0; W.sort!"a > b"; B.sort!"a > b"; // 白から積んでいく int curW = 0, curB = 0, tmp = 1; while (true) { while (curB < NB && B[curB] >= W[curW]) curB++; if (curB == NB) break; ++tmp; while (curW < NW && W[curW] >= B[curB]) curW++; if (curW == NW) break; ++tmp; } ans = max(ans, tmp); // 黒から積んでいく curW = 0, curB = 0, tmp = 1; while (true) { while (curW < NW && W[curW] >= B[curB]) curW++; if (curW == NW) break; ++tmp; while (curB < NB && B[curB] >= W[curW]) curB++; if (curB == NB) break; ++tmp; } ans = max(ans, tmp); // 答えの出力 writeln(ans); }