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>
#define ss second
#define ff first
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 1e5 + 123;
const int mod = 998244353;
const int inf = 1e9;
void solve() {
int n;
cin >> n;
int a, ans = 1, x = -1;
set<int> s;
while(n) {
cin >> a;
if(a > x) {
x = a;
s.insert(x);
}
else {
ans++;
x = a;
s.insert(x);
n--;
break;
}
n--;
}
while(n--) {
cin >> a;
if(s.upper_bound(x) != s.upper_bound(a))ans++;
s.insert(a);
x = a;
}
cout << ans;
}
int main() {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
int t = 1;
//cin >> t;
while(t--) {
solve();
}
return 0;
}
# | 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... |