This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Suleyman Atayew
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#define N 1000010
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define inf 1000000007
#define pii pair <int, int>
using namespace std;
int n;
int v[N];
set <int> S;
int main()
{
cin >> n;
int ans = 0;
S.insert(1e9);
for(int i = 1; i <= n; i++)
cin >> v[i];
for(int i = 1; i <= n; i++) {
int h = i+1;
int y = *S.lower_bound(v[i]);
while(h <= n) {
int x = *S.lower_bound(v[h]);
if(x != y || v[h] < v[h-1]) break;
h++;
}
for(int j = i; j < h; j++) S.insert(v[j]);
ans ++;
i = h-1;
}
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... |