Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int N;
- cin >> N;
- double a[N];
- for (int i = 0; i < N; i++) {
- cin >> a[i];
- }
- sort(&a[0], &a[N]);
- int counter = 1;
- int prev = 0;
- int i = 0;
- while (i < N) {
- if ((a[prev] + 1.00) >= a[i]) {
- i++;
- } else {
- prev = i;
- counter++;
- }
- }
- cout << counter;
- }
Advertisement
Add Comment
Please, Sign In to add comment