-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtopo.cpp
More file actions
47 lines (46 loc) · 853 Bytes
/
topo.cpp
File metadata and controls
47 lines (46 loc) · 853 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
#include <iostream>
#include <list>
#include <iterator>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
int N,x,c=0,a=1;
cin >> N;
int r = N+1;
int count[r];
//input
for (int i =0;i<r;i++){
count[i] = 0 ;
}
for(int i =0;i<N;i++){
cin >> x;
c = x-(a) ;
if(c > 0 ){
count[i] = c;
}
else if(c<0){
c = c+N;
count[i] = c;
}
a++;
}
int arr[r] ;
for (int i =0;i<r;i++){
arr[i] = 0 ;
}
// for(int i =0 ;i<N;i++){
// cout << count[i] << endl;
// }
for (int i =0;i<r;i++){
arr[count[i]] += 1;
}
int max=0;
for (int i =0;i<N;i++){
if(count[i] >= max){
max = arr[i];
}
}
cout << max << '\n';
return 1;
}