-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathanu_has_a_function.cpp
More file actions
executable file
·44 lines (36 loc) · 1.2 KB
/
anu_has_a_function.cpp
File metadata and controls
executable file
·44 lines (36 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// g++ anu_has_a_function.cpp -o anu_has_a_function && ./anu_has_a_function
/*
*/
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL)
#define endl '\n'
#define ll long long int
using namespace std;
#define pii pair <ll , ll >
#define pb push_back
#define deb(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl
#define loop(x) for (int i = 0; i < x; i++)
#define vin vector<int>
#define vll vector<long long>
bool fun(ll a, ll b){return a > b;}
int main(){
fastio;
int n;
cin >> n;
vll arr(n);
loop(n) cin >> arr[i];
sort(arr.begin(), arr.end());
vector<pair<int, int>> new_arr;
new_arr.push_back({arr[0], 1});
int last = 0;
for(int i = 1; i < n; i++){
if(arr[i] == new_arr[last].first) new_arr[last].second++;
else new_arr.push_back({arr[i], 1}), last++;
}
int i = 0;
for(int i = 0; i <= last; i++) if(new_arr[i].second == 1) break;
cout << new_arr[i].first << " ";
int temp = new_arr[i].first;
for(auto j : arr) if(j != temp) cout << j << " "; cout << endl;
}