标签:clu 条件 scanf str main 代码 std algorithm code
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int record[100000];
int main(){
int n, max = 0, count = 0;
scanf("%d", &n);
vector<int> a(n), b(n);
for(int i = 0; i < n; i++){
scanf("%d", &a[i]);
b[i] = a[i];
}
sort(a.begin(), a.end());
for(int i = 0; i < n; i++){
if(a[i] == b[i] && b[i] > max){
record[count++] = a[i];
}
if(b[i] > max) max = b[i];
}
printf("%d\n", count);
for(int i = 0; i < count; i++){
if(i != 0) printf(" ");
printf("%d", record[i]);
}
printf("\n");
return 0;
}
标签:clu 条件 scanf str main 代码 std algorithm code
原文地址:https://www.cnblogs.com/tsruixi/p/11896674.html