結果

問題 No.2851 Make Pairs
コンテスト
ユーザー tnakao0123
提出日時 2024-08-29 13:38:26
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 534 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 145 ms
コンパイル使用メモリ 52,964 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2026-07-05 13:46:17
合計ジャッジ時間 1,184 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 2851.cc:  No.2851 Make Pairs - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

int as[MAX_N], cs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i), as[i]--;
  
  for (int i = 0; i < n; i++) cs[as[i]]++;

  int sum = 0;
  for (int i = 0; i < n; i++) sum += (cs[i] >> 1);
  
  printf("%d\n", sum);
  
  return 0;
}
0