-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsch.cpp
More file actions
49 lines (41 loc) · 875 Bytes
/
sch.cpp
File metadata and controls
49 lines (41 loc) · 875 Bytes
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
#include <stdio.h>
#define maxN 100010
using namespace std;
int servers[maxN] = {0};
int main(){
int N, num;
freopen("sch.in", "r", stdin);
//freopen("sch.out", "w", stdout);
scanf("%d", &N);
for (int i=0; i<N; i++) {
scanf("%d", &num);
servers[num]++;
}
int max1 = 0;
int max2 = 0;
int max3 = 0;
int index1, index2, index3;
for (int i=0; i<N; i++) {
printf("Server %d was visited %d times\n", i, servers[i]);
if(servers[i] > max1){
if(max1 > max2){
max2 = max1;
index2 = index1;
}
max1 = servers[i];
index1 = i;
} else if(servers[i] > max2){
if(max2 > max3){
max3 = max2;
index3 = index2;
}
max2 = servers[i];
index2 = i;
} else if(servers[i] > max3){
max3 = servers[i];
index3 = i;
}
}
printf("%d %d %d\n", index1, index2, index3);
return 0;
}