結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    int S[3] = {}, T[3] = {};
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        S[a]++;
    }
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        T[a]++;
    }
    int ans = S[2]*N + T[2]*N - S[2]*T[2];
    if(S[2] == 0 && T[2] == 0){
        ans += max(S[1], T[1]);
    }else if(S[2] == 0){
        ans += T[1];
    }else if(T[2] == 0){
        ans += S[1];
    }
    cout << ans << endl;
    return 0;
}
0