結果

問題 No.110 しましまピラミッド
ユーザー IDID
提出日時 2016-06-10 15:19:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,665 bytes
コンパイル時間 1,371 ms
コンパイル使用メモリ 80,292 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 03:54:06
合計ジャッジ時間 1,866 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

  int nw, nb;
  cin >> nw;
  vi w(nw);
  rep(i,0,nw) cin >> w[i];
  cin >> nb;
  vi b(nb);
  rep(i,0,nb) cin >> b[i];

  sort(w.begin(), w.end(), greater<int>());
  sort(b.begin(), b.end(), greater<int>());

  int ans1 = 1;
  int i = 0, j = 0, num = w[0];
  bool flag = true;
  while(i < w.size() || j < b.size()) {
    if(flag) {
      while(j < b.size() && num <= b[j]) j++;
      if(j == b.size()) break;
      num = b[j];
      ans1++;
    } else {
      while(i < w.size() && num <= w[i]) i++;
      if(i == w.size()) break;
      num = w[i];
      ans1++;
    }
    flag = !flag;
  }

  int ans2 = 1;
  i = j = 0;
  num = b[0];
  flag = false;
  while(i <= w.size() || j <= b.size()) {
    if(flag) {
      while(j < b.size() && num <= b[j]) j++;
      if(j == b.size()) break;
      num = b[j];
      ans2++;
    } else {
      while(i < w.size() && num <= w[i]) i++;
      if(i == w.size()) break;
      num = w[i];
      ans2++;
    }
    flag = !flag;
  }

  cout << max(ans1, ans2) << endl;

	return 0;
}
0