結果
問題 | No.1225 I hate I hate Matrix Construction |
ユーザー |
|
提出日時 | 2020-09-12 16:08:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 882 bytes |
コンパイル時間 | 1,866 ms |
コンパイル使用メモリ | 167,580 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-02 06:06:13 |
合計ジャッジ時間 | 2,827 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 35 |
ソースコード
#include <algorithm> #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = (int)n - 1; i > -1; i--) #define all(x) (x).begin(), (x).end() #define ll long long #define ld long double #define INF 1000000000000000000 typedef pair<ll, ll> pll; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> S(N), T(N); vector<vector<int>> mat(N, vector<int>(N, 0)); rep(i, N) { cin >> S[i]; } rep(i, N) { cin >> T[i]; } int a = count(all(S), 2), b = count(all(T), 2), c = count(all(S), 1), d = count(all(T), 1); if (a && b) { cout << N * (a + b) - a * b << endl; } else if (a) { cout << N * a + c << endl; } else if (b) { cout << N * b + d << endl; } else { cout << max(c, d) << endl; } }