This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int arr[1000005];
const int inf = 1e9 + 7;
int main(){
int n;
cin >> n;
for(int i = 0; i < n; i++)
cin >> arr[i];
set < int > st;
st.insert(inf);
int ans = 0;
for(int i = 0; i < n; ){
ans++;
int j = i + 1;
int x = *st.upper_bound(arr[i]);
st.insert(arr[i]);
while (j < n && arr[j - 1] <= arr[j] && arr[j] <= x){
st.insert(arr[j]);
j++;
}
i = j;
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |