結果

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

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n;
  cin>>n;
  
  int a1=0,a2=0,b1=0,b2=0;
  int x;
  rep(i,n){
    cin>>x;
    if(x==1) a1++;
    if(x==2) a2++;
  }
  rep(i,n){
    cin>>x;
    if(x==1) b1++;
    if(x==2) b2++;
  }
  
  if(a2>0 && b2>0){
    cout<<(a2+b2)*n-a2*b2<<endl;
  }
  else if(a2>0){
    cout<<a2*n+a1<<endl;
  }
  else if(b2>0){
    cout<<b2*n+b1<<endl;
  }
  else{
    cout<<max(a1,b1)<<endl;
  }
  
  return 0;
}
0