結果

問題 No.110 しましまピラミッド
ユーザー kuisibakuisiba
提出日時 2016-10-14 17:09:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,387 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 66,412 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 23:00:57
合計ジャッジ時間 1,567 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  int w;
  cin >> w;
  vector<int> white(w);
  for (auto& i : white) {
    cin >> i;
  }
  sort(white.begin(), white.end());

  int b;
  cin >> b;
  vector<int> black(b);
  for (auto& i : black) {
    cin >> i;
  }
  sort(black.begin(), black.end());

  int base_w = 1;
  int base_b = 1;
  int temp = -1;
  vector<int> white2 = white;
  vector<int> black2 = black;

  for (int i = (int)white.size() - 1; i >= 0; i--) {
    for (int j = (int)black.size() - 1; j >= 0; j--) {
      if (white.at(i) > black.at(j)) {
        temp = black.at(j);
        base_w++;
        break;
      } else {
        black.pop_back();
      }
    }
    if (white.at(i) < temp) {
      temp = white.at(i);
      base_w++;
    } else {
      white.pop_back();
      continue;
    }
  }

  for (int i = (int)black2.size() - 1; i >= 0; i--) {
    for (int j = (int)white2.size() - 1; j >= 0; j--) {
      if (black2.at(i) > white2.at(j)) {
        temp = white2.at(j);
        base_b++;
        break;
      } else {
        white2.pop_back();
      }
    }
    if (black2.at(i) < temp) {
      temp = black2.at(i);
      base_b++;
    } else {
      black2.pop_back();
      continue;
    }
  }
  cout << max(base_w, base_b) << endl;
  return 0;
}

0