結果

問題 No.1470 Mex Sum
ユーザー Noboru2020Noboru2020
提出日時 2021-04-09 21:32:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 3,083 ms
コンパイル使用メモリ 174,784 KB
実行使用メモリ 7,512 KB
最終ジャッジ日時 2023-09-07 10:02:37
合計ジャッジ時間 7,235 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 7 ms
4,384 KB
testcase_03 AC 6 ms
4,380 KB
testcase_04 AC 7 ms
4,384 KB
testcase_05 AC 7 ms
4,384 KB
testcase_06 AC 7 ms
4,380 KB
testcase_07 AC 7 ms
4,380 KB
testcase_08 AC 7 ms
4,380 KB
testcase_09 AC 7 ms
4,384 KB
testcase_10 AC 7 ms
4,380 KB
testcase_11 AC 7 ms
4,380 KB
testcase_12 AC 60 ms
7,008 KB
testcase_13 AC 58 ms
7,108 KB
testcase_14 AC 59 ms
7,008 KB
testcase_15 AC 59 ms
7,072 KB
testcase_16 AC 58 ms
7,024 KB
testcase_17 AC 58 ms
7,228 KB
testcase_18 AC 57 ms
7,004 KB
testcase_19 AC 59 ms
7,036 KB
testcase_20 AC 60 ms
7,228 KB
testcase_21 AC 60 ms
6,992 KB
testcase_22 AC 60 ms
6,968 KB
testcase_23 AC 61 ms
7,512 KB
testcase_24 AC 60 ms
6,992 KB
testcase_25 AC 60 ms
6,968 KB
testcase_26 AC 62 ms
7,232 KB
testcase_27 AC 62 ms
7,072 KB
testcase_28 AC 62 ms
7,224 KB
testcase_29 AC 62 ms
6,924 KB
testcase_30 AC 60 ms
7,008 KB
testcase_31 AC 62 ms
7,120 KB
testcase_32 AC 66 ms
7,004 KB
testcase_33 AC 62 ms
6,924 KB
testcase_34 AC 63 ms
6,996 KB
testcase_35 AC 64 ms
6,932 KB
testcase_36 AC 61 ms
7,068 KB
testcase_37 AC 31 ms
4,696 KB
testcase_38 AC 30 ms
4,600 KB
testcase_39 AC 30 ms
4,616 KB
testcase_40 AC 31 ms
4,592 KB
testcase_41 AC 32 ms
4,548 KB
testcase_42 AC 32 ms
4,696 KB
testcase_43 AC 32 ms
4,732 KB
testcase_44 AC 32 ms
4,636 KB
testcase_45 AC 32 ms
4,696 KB
testcase_46 AC 32 ms
4,604 KB
testcase_47 AC 31 ms
4,632 KB
testcase_48 AC 32 ms
4,696 KB
testcase_49 AC 32 ms
4,540 KB
testcase_50 AC 32 ms
4,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;cin>>N;
  vector<int>vec(N);
  map<int,int>mp;
  for(int &i:vec){
    cin>>i;
    mp[i]++;
  }
  int ans=0,memo=0;
  ans+=mp[1]*mp[2]*3;
  memo+=mp[1]*mp[2];
  ans+=(mp[1]*(mp[1]-1)/2+mp[1]*(N-mp[1]-mp[2]))*2;
  memo+=(mp[1]*(mp[1]-1)/2+mp[1]*(N-mp[1]-mp[2]));
  ans+=N*(N-1)/2-memo;
  cout<<ans<<endl;
}
0