Created
September 18, 2016 17:17
-
-
Save ngobach/e67a5079a359dc0ef0f8c8bea75437b2 to your computer and use it in GitHub Desktop.
P161PROC.CPP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main(){ | |
// freopen("input.txt","r",stdin); | |
int n,k; | |
cin>>n>>k; | |
int a[n+5] = {0},t = 1, b[n+5] = {0}; | |
cin>>a[0]; | |
while(n-1 > 0){ | |
n--; | |
int c; | |
cin>>c; | |
if(c == a[t-1]) continue; | |
a[t] = c; | |
t++; | |
} | |
int stress,result = -1,kq = 1,d,c; | |
// for(int i = 1;i<=k;i++){ | |
// stress = t-1; | |
// d = 0,c = t-1; | |
// while(a[d] == i) stress--,d++; | |
// while(a[c] == i) stress--,c--; | |
// for(int j = d+1;j <c;j++){ | |
// if(a[j] == i && a[j-1] == a[j+1]) stress -= 2; | |
// else if(a[j] == i)stress--; | |
// } | |
// if(result > stress) result = stress,kq = i; | |
// } | |
for (int i=1;i<t-1;i++) { | |
if (a[i-1]==a[i+1]) b[a[i]] += 2; else b[a[i]] ++; | |
} | |
b[a[0]]++; | |
b[a[t-1]]++; | |
for (int i=1;i<=k;i++) { | |
if (b[i]>result) { | |
kq = i; | |
result = b[i]; | |
} | |
} | |
cout<<kq; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment