-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsecond_stat.cpp
84 lines (71 loc) · 998 Bytes
/
second_stat.cpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <stdio.h>
#include <iostream>
//#include <math.h>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
vector<int> myfunc(vector<int>&vec,int nw)
{
//printf("hoorah\n");
int i=1,count=0;
int k=i-1;
for(i=1;i<nw;i++)
{
if(vec[k]==vec[i])
{
count++;
}
else if(count > 0 && vec[k]!= vec[i])
{
int j=0;
for(j=0;j<count;j++)
vec.erase(vec.begin());
count=0;
}
}
printf("%d\n",vec[1]);
/*for (int i = 0; i < nw-1; ++i)
{
printf("%d ",vec[i]);
}
*/
return vec;
}
int main()
{
int n;
scanf("%d",&n);
int nw=n;
std::vector<int> vec;
//int arr[105];
int i;
while(n--)
{
int a=0;
scanf("%d",&a);
vec.push_back(a);
i++;
}
std::sort(vec.begin(),vec.end());
i=1;
int j=i-1;
int flag=0;
for (int i = 1; i < nw; i++)
{
if(vec[j] == vec[i])
{
flag++;
}
}
//printf("flag %d\n", flag);
if(nw > 1 && nw !=flag+1)
{
myfunc(vec,nw);
}
else
{
printf("NO\n");
}
return 0;
}