Skip to content

Instantly share code, notes, and snippets.

@lazycipher
Created January 18, 2021 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazycipher/462a490dd8f824e0b51c85778019c1d5 to your computer and use it in GitHub Desktop.
Save lazycipher/462a490dd8f824e0b51c85778019c1d5 to your computer and use it in GitHub Desktop.
Drinks Choosing Codeforces
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, k;
cin >> n >> k;
int arr[k] = {0};
int goods = 0, bads = 0;
int inp;
for (int i = 0; i < n; i++)
{
cin >> inp;
arr[inp - 1]++;
}
for (int i = 0; i < k; i++)
{
goods = goods + arr[i] / 2;
bads = bads + arr[i] % 2;
}
int total = goods * 2 + ceil((float)bads / 2);
cout << total;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment