Submission #70542878


Source Code Expand

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

/////////////////// メイン ///////////////////

int main () {
  
  //////////////////// 入力 ////////////////////

  int n;
  cin >> n;

  vector<int> a(n);
  for (int i=0; i<n; i++) {
    cin >> a.at(i);
  }

  //////////////// 出力変数定義 ////////////////

  long long result = 0;

  //////////////////// 処理 ////////////////////

  // 何が何個あるか数えるvector、中身がnまで欲しいのでサイズはn+1
  vector<int> counters(n+1);

  // aの中身を集計する
  for (int i : a) counters.at(i)++;

  // 各数値について、「それを2個と別のを1個」選ぶ方法を求め、合計していく
  for (int i : counters) result += 1LL*i*(i-1)*(n-i)/2;

  //////////////////// 出力 ////////////////////

  cout << result << endl;

  //////////////////// 終了 ////////////////////

  return 0;

}

Submission Info

Submission Time
Task C - Odd One Subsequence
User wightou
Language C++ 23 (gcc 12.2)
Score 300
Code Size 933 Byte
Status AC
Exec Time 37 ms
Memory 4892 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 28
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3520 KiB
example_01.txt AC 1 ms 3480 KiB
hand_00.txt AC 36 ms 4720 KiB
hand_01.txt AC 37 ms 4804 KiB
hand_02.txt AC 26 ms 4764 KiB
hand_03.txt AC 1 ms 3396 KiB
hand_04.txt AC 1 ms 3524 KiB
hand_05.txt AC 34 ms 4804 KiB
random_00.txt AC 35 ms 4888 KiB
random_01.txt AC 36 ms 4760 KiB
random_02.txt AC 35 ms 4644 KiB
random_03.txt AC 36 ms 4752 KiB
random_04.txt AC 35 ms 4800 KiB
random_05.txt AC 32 ms 4804 KiB
random_06.txt AC 33 ms 4732 KiB
random_07.txt AC 33 ms 4676 KiB
random_08.txt AC 32 ms 4656 KiB
random_09.txt AC 32 ms 4660 KiB
random_10.txt AC 26 ms 4720 KiB
random_11.txt AC 25 ms 4744 KiB
random_12.txt AC 26 ms 4648 KiB
random_13.txt AC 26 ms 4764 KiB
random_14.txt AC 26 ms 4660 KiB
random_15.txt AC 19 ms 4760 KiB
random_16.txt AC 19 ms 4712 KiB
random_17.txt AC 20 ms 4892 KiB
random_18.txt AC 19 ms 4720 KiB
random_19.txt AC 19 ms 4792 KiB