結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー YamaKasa
提出日時 2020-09-12 16:49:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 1,580 ms
コンパイル使用メモリ 161,468 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-01-02 07:37:33
合計ジャッジ時間 2,819 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int S[N], T[N];
    int s1 = 0, s2 = 0, t1 = 0, t2 = 0;
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        if (S[i] == 2) s2++;
    }
    for (int i = 0; i < N; i++) {
        cin >> T[i];
        if (T[i] == 2) t2++;
    }
    for (int i = 0; i < N; i++) {
        if (s2 == 0 && T[i] == 1) t1++;
        if (t2 == 0 && S[i] == 1) s1++;
    }
    //int k = N * s2 + N * t2 - s2 * t2;
    int ans = N * s2 + N * t2 - s2 * t2 + max(s1, t1);
    cout << ans << "\n";
}
0