結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー mot
提出日時 2020-09-12 00:57:33
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,004 bytes
コンパイル時間 811 ms
コンパイル使用メモリ 84,404 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-29 11:36:27
合計ジャッジ時間 2,255 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int one1=0, one2=0, two1=0, two2=0;
  int tmp;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(tmp==1) one1++;
    if(tmp==2) two1++;
  }
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(tmp==1) one2++;
    if(tmp==2) two2++;
  }
  int ans = 0;
  if(two1>0 && two2>0) ans = two1*N+two2*N-two1*two2;
  if(two1>0 && two2==0) {
    ans += two1*N;
    ans += one1;
  }
  if(two2>0 && two1==0) {
    ans += two2*N;
    ans += one2;
  }
  if(two1==0 && two2==0) {
    ans = max(one1, one2);
  }
  cout<<ans<<endl;
}

0