結果
問題 | No.110 しましまピラミッド |
ユーザー |
![]() |
提出日時 | 2015-06-24 22:50:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 786 bytes |
コンパイル時間 | 926 ms |
コンパイル使用メモリ | 64,968 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-31 11:10:56 |
合計ジャッジ時間 | 1,931 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n[2]; cin>>n[0]; vector<int> w(n[0]); for(int i=0;i<n[0];i++) cin>>w[i]; sort(w.begin(),w.end()); cin>>n[1]; vector<int> b(n[1]); for(int i=0;i<n[1];i++) cin>>b[i]; sort(b.begin(),b.end()); int scr[2]={0,0},temp=0,cnt[2]; for(int i=0;i<2;i++){ temp=0; cnt[0]=0; cnt[1]=0; int turn=i; while(1){ bool end=true; while(cnt[turn]<n[turn]){ if(turn==0&&w[cnt[turn]]>temp){ scr[i]++; end=false; temp=w[cnt[turn]]; break; } else if(turn==1&&b[cnt[turn]]>temp){ scr[i]++; end=false; temp=b[cnt[turn]]; break; } else cnt[turn]++; } if(end) break; turn^=1; } } cout<<max(scr[0],scr[1])<<endl; return 0; }