https://pintia.cn/problem-sets/994805260223102976/problems/994805278589960192
测试点2是没有主元的时候 但是 有点奇怪啊
#include <iostream>
using namespace std;
int leftmax[100010] = {0}, rightmin[100010] = {0}, n, num[100010], tmpmax = -1, tmpmin = 999999999;
int result[100010];
int main(){
cin >> n;
fill(rightmin, rightmin+n, 999999999);
leftmax[0] = -1; rightmin[n-1] = 999999999;
for(int i = 0; i < n; i++)
cin >> num[i];
for(int i = 1; i < n; i++){
leftmax[i] = (num[i-1] > leftmax[i-1]) ? num[i-1] : leftmax[i-1];
int j = n-i-1;
rightmin[j] = (rightmin[j+1] < num[j+1]) ? rightmin[j+1] : num[j+1];
}
int cnt = 0, flag = 0;
for(int i = 0; i < n; i++){
if(num[i] > leftmax[i] && num[i] < rightmin[i])
result[cnt++] = num[i];
}
if(cnt){
cout << cnt << endl << result[0];
for(int i = 1; i < cnt; i++)
cout << " " << result[i];
}else cout << cnt << endl << endl;
return 0;
}