結果
| 問題 | No.121 傾向と対策:門松列(その2) | 
| コンテスト | |
| ユーザー |  nmnmnmnmnmnmnm | 
| 提出日時 | 2015-01-09 00:00:02 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,417 bytes | 
| コンパイル時間 | 846 ms | 
| コンパイル使用メモリ | 97,632 KB | 
| 実行使用メモリ | 55,000 KB | 
| 最終ジャッジ日時 | 2024-06-13 03:23:58 | 
| 合計ジャッジ時間 | 6,842 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | WA * 4 RE * 5 | 
ソースコード
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
 
#define MOD 1000000009
int d1[100001];
int d2[100001];
int main(){
  int n;
  cin>>n;
  map<int,int> ma;
  rep(i,0,n){
    int a;
    cin>>a;
    ma[a]++;
  }
  vector<int> v;
  map<int,int>::iterator itr = ma.begin();
  while(itr!=ma.end()){
    v.pb((*itr).se);
    itr++;
  }
  clr(d1,0);
  clr(d2,0);
  rep(i,0,v.sz){
    d1[i] = v[i];
  }
  rep(i,1,v.sz){
    d1[i]+=d1[i-1];
  }
  rep(i,0,v.sz){
    if(v[i]>1){
      d2[i] = v[i]*(v[i]-1)/2;
    }
  }
  rep(i,1,v.sz){
    d2[i] += d2[i-1];
  }
  int ans = 0;
  rep(i,0,v.sz){
    int a = v[i];
    int b = d1[v.sz-1]-d1[a];
    int c = d1[a-1];
    int d = d2[v.sz-1]-d2[a];
    int e = d2[a-1];
    if(b>1){
      ans += b*(b-1)/2;
      ans -= d;
    }    
    if(c>1){
      ans += c*(c-1)/2;
      ans -= e;
    }
  }
  cout << ans << endl;
  return 0;
}
            
            
            
        