結果
| 問題 |
No.1470 Mex Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-09 21:32:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 65 ms / 2,000 ms |
| コード長 | 395 bytes |
| コンパイル時間 | 2,049 ms |
| コンパイル使用メモリ | 176,852 KB |
| 実行使用メモリ | 7,424 KB |
| 最終ジャッジ日時 | 2024-06-25 04:18:25 |
| 合計ジャッジ時間 | 5,720 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 49 |
ソースコード
#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;
}