update
This commit is contained in:
parent
0661f341bd
commit
e1d8fac250
@ -1,16 +1,35 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
using std::cin, std::cout, std::iostream;
|
||||
using std::cin, std::cout, std::iostream, std::max, std::for_each_n;
|
||||
|
||||
constexpr size_t MAX_N {(size_t)5e4+5};
|
||||
int n, arr[MAX_N], len[MAX_N], ans1, ans2;
|
||||
int arr[MAX_N], len[MAX_N], ans1, ans2{1}, n, last_max;
|
||||
|
||||
int main(){
|
||||
iostream::sync_with_stdio(false), cin.tie(0), cout.tie(0);
|
||||
|
||||
cin>>n;
|
||||
for(size_t i=0;i<n;i++){
|
||||
cin>>arr[i];
|
||||
}
|
||||
while(cin>>arr[n++]);
|
||||
|
||||
for(int i=0;i<n;i++){
|
||||
for(int j=i-1;j>=0;j--){ //j<i
|
||||
if(arr[j]>=arr[i] && len[i]<len[j]+1){
|
||||
len[i] = len[j] + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
for_each_n(len,n,[](decltype(*len) e){
|
||||
ans1 = std::max(ans1,e);
|
||||
});
|
||||
last_max = arr[0];
|
||||
for_each_n(arr+1,n,[](decltype(*arr) e){
|
||||
if(last_max < e){
|
||||
ans2++;
|
||||
last_max = e;
|
||||
}else{
|
||||
last_max = e;
|
||||
}
|
||||
});
|
||||
|
||||
cout<<ans1<<'\n'<<ans2<<'\n';
|
||||
}
|
Loading…
Reference in New Issue
Block a user