結果

問題 No.110 しましまピラミッド
ユーザー fuu32fuu32
提出日時 2018-02-07 13:23:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,286 bytes
コンパイル時間 3,420 ms
コンパイル使用メモリ 170,008 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-12 16:46:56
合計ジャッジ時間 3,702 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,356 KB
testcase_10 WA -
testcase_11 AC 1 ms
4,372 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,352 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,348 KB
testcase_19 WA -
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,352 KB
testcase_22 WA -
testcase_23 AC 1 ms
4,368 KB
testcase_24 AC 1 ms
4,352 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 1 ms
4,352 KB
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=9000000009;


signed main(){
  int n;
  cin>>n;
  vector<int> w(n);
  REP(i,n)cin>>w[i];
  sort(ALL(w));
  int m;
  cin>>m;
  vector<int> b(m);
  REP(i,m)cin>>b[i];
  sort(ALL(b));
  int ans1=1,bot=w.back(),white=n-1,black=m-1;
  bool turn=true;//白が最下層
  REP(j,n+m){
    if(turn){
      for(int i=black;i>=0;i--){
        if(b[i]<bot){
          bot=b[i];ans1++;black=i;turn=false;break;
        }
      }
    }else{
      for(int i=white;i>=0;i--){
        if(w[i]<bot){
          bot=w[i];ans1++;white=i;turn=true;break;
        }
      }
    }
  }

  int ans2=1;
  bot=b.back(),white=n-1,black=m-1;
  turn=true;//黒が最下層
  REP(j,n+m){
    if(!turn){
      for(int i=black;i>=0;i--){
        if(b[i]<bot){
          bot=b[i];ans2++;black=i;turn=false;break;
        }
      }
    }else{
      for(int i=white;i>=0;i--){
        if(w[i]<bot){
          bot=w[i];ans2++;white=i;turn=true;break;
        }
      }
    }
  }
  cout<<max(ans1,ans2)<<endl;

  return 0;
}
0