結果
| 問題 | No.1225 I hate I hate Matrix Construction | 
| コンテスト | |
| ユーザー |  w2w2 | 
| 提出日時 | 2020-09-11 21:44:06 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 5 ms / 2,000 ms | 
| コード長 | 1,388 bytes | 
| コンパイル時間 | 2,730 ms | 
| コンパイル使用メモリ | 194,272 KB | 
| 最終ジャッジ日時 | 2025-01-14 10:16:50 | 
| ジャッジサーバーID (参考情報) | judge1 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 35 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N;
    cin >> N;
    vector<ll> S(N);
    vector<ll> T(N);
    REP(i,N)cin >> S[i];
    REP(i,N)cin >> T[i];
    ll St = 0,Tt = 0,So = 0,To = 0;;
    REP(i,N){
        if(S[i] == 2){
            St += 1;
        }
        if(T[i] == 2){
            Tt += 1;
        }
        if(S[i] == 1){
            So += 1;
        }
        if(T[i] == 1){
            To += 1;
        }
    }
    ll ans = Tt*N + St * N - St*Tt;
    if(St == 0 && Tt == 0){
        ans += max(So,To);
    }else if(St == 0){
        ans += To;
    }else if(Tt == 0){
        ans += So;
    }
    cout << ans << "\n";
}
            
            
            
        