結果
| 問題 |
No.1225 I hate I hate Matrix Construction
|
| コンテスト | |
| ユーザー |
Shibuyap
|
| 提出日時 | 2020-09-11 21:50:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 2,000 ms |
| コード長 | 1,129 bytes |
| コンパイル時間 | 1,780 ms |
| コンパイル使用メモリ | 193,644 KB |
| 最終ジャッジ日時 | 2025-01-14 10:19:39 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 35 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 200005
int main() {
int n; cin >> n;
int a[n] = {};
int ma = 0;
rep(i,n){
cin >> a[i];
ma = max(ma,a[i]);
}
int mb = 0;
int b[n] = {};
rep(i,n){
cin >> b[i];
mb = max(mb,b[i]);
}
int ans = 0;
if(ma == 2 || mb == 2){
int cnt1 = 0, cnt2 = 0;
rep(i,n){
if(a[i] == 2) cnt1++;
if(b[i] == 2) cnt2++;
}
ans = n * cnt1 + n * cnt2 - cnt1 * cnt2;
if(cnt2==0){
rep(i,n) if(a[i]==1) ans++;
}else if(cnt1 == 0){
rep(i,n) if(b[i]==1) ans++;
}
}else{
int cnt1 = 0, cnt2 = 0;
rep(i,n){
if(a[i] == 1) cnt1++;
if(b[i] == 1) cnt2++;
}
ans = max(cnt1,cnt2);
}
cout << ans << endl;
return 0;
}
Shibuyap