|
|
|
|
|
by mrkeen
21 days ago
|
|
> Test the speed in our live coding playground: playground.kog.ai > Dsatur in Haskell #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++) cin >> v[i];
sort(v.begin(), v.end());
int i = 0, j = n - 1;
while (i < j) {
while (i < j && v[i] == v[j]) i++;
while (i < j && v[j] == v[i]) j--;
cout << v[i] << " ";
i++;
j--;
}
return 0;
}
Haha. It was fast though. |
|