結果
| 問題 | No.1225 I hate I hate Matrix Construction | 
| コンテスト | |
| ユーザー |  misora192 | 
| 提出日時 | 2020-11-06 21:03:18 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 903 bytes | 
| コンパイル時間 | 1,557 ms | 
| コンパイル使用メモリ | 168,536 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-22 11:58:14 | 
| 合計ジャッジ時間 | 2,835 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 35 | 
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)
using namespace std;
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> s(n), t(n);
	rep(i, n) cin >> s[i];
	rep(i, n) cin >> t[i];
	int s2cnt = 0, t2cnt = 0;
	rep(i, n) if(s[i] == 2) s2cnt++;
	rep(i, n) if(t[i] == 2) t2cnt++;
	ll ans = 0;
	ans += s2cnt * n;
	ans += t2cnt * (n - s2cnt);
	if(s2cnt == 0 && t2cnt > 0){
		rep(i, n) if(t[i] == 1) ans++;
	}else if(s2cnt > 0 && t2cnt == 0){
		rep(i, n) if(s[i] == 1) ans++;
	}else if(s2cnt == 0 && t2cnt == 0){
		ll m1 = 0, m2 = 0;
		rep(i, n) if(s[i] == 1) m1++;
		rep(i, n) if(t[i] == 1) m2++;
		ans += max(m1, m2);
	}
	cout << ans << endl;
}
            
            
            
        