Skip to content

Instantly share code, notes, and snippets.

@shrubb
Created September 12, 2015 14:21
Show Gist options
  • Save shrubb/29c3d32412afe5817681 to your computer and use it in GitHub Desktop.
Save shrubb/29c3d32412afe5817681 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
#include <limits.h>
int main(int, char**)
{
int n;
std::cin >> n;
std::vector<long long> count(10001);
long long minimum = INT_MAX;
for (int i = 0 ; i < n; ++i) {
long long k;
std::cin >> k;
++count[k];
minimum = std::min(minimum, k);
}
for (int i = 10000; i >= 1; --i) {
if (count[i]) {
count[i - minimum] += count[i];
count[minimum] += count[i];
minimum = std::min(minimum, i - minimum);
}
if (i == minimum)
break;
}
std::cout << count[minimum];
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment