結果
問題 |
No.110 しましまピラミッド
|
ユーザー |
![]() |
提出日時 | 2016-02-28 03:12:44 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 937 bytes |
コンパイル時間 | 728 ms |
コンパイル使用メモリ | 60,080 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-31 11:17:49 |
合計ジャッジ時間 | 1,782 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#include<iostream> #include<algorithm> using namespace std; #define NwMAX 10 #define NbMAX 10 #define BLACK 0 #define WHITE 1 int main(){ int Nw,Nb; int W[NwMAX],B[NbMAX]; int ans=0; int h=0,wb=0; int i,j; int turn; cin>>Nw; for(int i=0;i<Nw;i++) cin>>W[i]; cin>>Nb; for(int i=0;i<Nb;i++) cin>>B[i]; sort(W,W+Nw); sort(B,B+Nb); wb=W[Nw-1]; h=1; i=Nw-2,j=Nb-1; turn=BLACK; while(1){ if(turn==BLACK){ if(j==-1) break; if(B[j]<wb){ wb=B[j]; turn=WHITE; h++; } j--; } else{ if(i==-1) break; if(W[i]<wb){ wb=W[i]; turn=BLACK; h++; } i--; } } ans=h; wb=B[Nb-1]; h=1; i=Nw-1,j=Nb-2; turn=WHITE; while(1){ if(turn==BLACK){ if(j==-1) break; if(B[j]<wb){ wb=B[j]; turn=WHITE; h++; } j--; } else{ if(i==-1) break; if(W[i]<wb){ wb=W[i]; turn=BLACK; h++; } i--; } } if(ans<h) ans=h; cout<<ans<<endl; }