結果

問題 No.2851 Make Pairs
ユーザー graythunder1graythunder1
提出日時 2024-08-25 14:10:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 675 bytes
コンパイル時間 1,368 ms
コンパイル使用メモリ 160,868 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-08-25 14:10:50
合計ジャッジ時間 2,311 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 67 ms
6,940 KB
testcase_03 AC 71 ms
6,944 KB
testcase_04 AC 100 ms
6,940 KB
testcase_05 AC 66 ms
6,940 KB
testcase_06 AC 72 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N;
  cin >> N;
  ll A[N];
  rep(i, N) cin >> A[i];

  sort(A, A+N);
  ll ans = 0;
  ll prev = A[0];
  ll cnt = 1;
  repi(i, 1, N) {
    if (A[i] == prev) {
      cnt++;
      if (cnt % 2 == 0) ans++;
    }
    else {
      cnt = 1;
    }
    prev = A[i];
  }

  cout << ans << endl;
  return 0;
}

0