結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー risujiroh
提出日時 2020-09-11 21:32:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 713 bytes
コンパイル時間 2,576 ms
コンパイル使用メモリ 249,820 KB
最終ジャッジ日時 2025-01-14 10:06:37
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (auto&& e : a) cin >> e;
  for (auto&& e : b) cin >> e;
  int a2 = count(begin(a), end(a), 2);
  int b2 = count(begin(b), end(b), 2);
  int res{};
  if (a2 and b2) {
    res = (a2 + b2) * n - a2 * b2;
  } else if (a2 == 0 and b2 == 0) {
    res = max(count(begin(a), end(a), 1), count(begin(b), end(b), 1));
  } else {
    if (b2) {
      swap(a2, b2);
      swap(a, b);
    }
    assert(a2 and b2 == 0);
    assert(count(begin(b), end(b), 1) == n);
    res = a2 * n + count(begin(a), end(a), 1);
  }
  cout << res << '\n';
}
0