PAT1045
程序员文章站
2022-07-15 14:01:05
...
#include<iostream>
#include <iomanip>
#include <cstdio>
#include<string>
#include<vector>
#include<array>
#include<math.h>
#include <ctype.h>
#include<algorithm>
using namespace std;
int main()
{
int c[100000];
int i,n,max = 0,count = 0;
cin >> n;
vector<int > a(n), b(n);
for (i = 0; i < n; i++)
{
cin >> a[i];
b[i] = a[i];
}
sort(a.begin(), a.end());
for (i = 0; i < n; i++)
{
if (b[i] == a[i] && b[i] > max)
c[count++] = b[i];
if (b[i] > max)
max = b[i];
}
cout << count<<"\n";
for (i = 0; i < count; i++)
{
if (i != count - 1)
cout << c[i] << ' ';
else
cout << c[i];
}
cout <<"\n";
return 0;
}
上一篇: PAT1059 乙级 java
下一篇: 国内最流行且免费的11个服务器监控工具