結果
| 問題 | No.1225 I hate I hate Matrix Construction | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-05-29 16:48:17 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 575 bytes | 
| コンパイル時間 | 1,664 ms | 
| コンパイル使用メモリ | 167,636 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-08 00:08:42 | 
| 合計ジャッジ時間 | 2,651 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 35 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
int main() {
  int n;
  cin >> n;
  vector<int> s(n), t(n);
  vector<int> cnts(3), cntt(3);
  rep(i,n) {
    cin >> s[i];
    cnts[s[i]]++;
  }
  rep(i,n) {
    cin >> t[i];
    cntt[t[i]]++;
  }
  int ans = 0;
  if (cnts[2] && cntt[2]) ans =  (cnts[2]+cntt[2])*n-cnts[2]*cntt[2];
  else if (cnts[2]) ans = cnts[2]*n+cnts[1];
  else if (cntt[2]) ans = cntt[2]*n+cntt[1];
  else ans = max(cnts[1], cntt[1]);
  cout << ans << endl;
}
            
            
            
        