贴代码
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main() {
int a[100], b, n, key,count,temp,i;
while(cin>>n) {
count = 1;
for (i = 0;i < n;i++) {
cin>>a[i];
}
key = a[0];
temp = 1;
for (i = 1; i < n; i++) {
if (a[i] == a[i - 1]) temp++;
else{
if(temp > count) {
count = temp;
key = a[i - 1];
temp = 1;
} else {
temp = 1;
}
}
}if(temp > count) {
count = temp;
key = a[i - 1];
}
cout<<key<<" "<<count<<endl;
}
return 0;
}