結果
問題 |
No.110 しましまピラミッド
|
ユーザー |
![]() |
提出日時 | 2016-02-28 03:11:50 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 957 bytes |
コンパイル時間 | 662 ms |
コンパイル使用メモリ | 60,036 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-24 11:58:17 |
合計ジャッジ時間 | 1,662 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 4 |
other | WA * 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); cout<<W[0]<<endl; 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; }