# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1128260 | _Temirhan | Money (IZhO17_money) | C++20 | 867 ms | 55224 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define sz(x) x.size()
#define F first
#define S second
#define nl '\n'
void Tima()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
const int N = 500 * 500 + 1;
const int inf = 1e12;
const int mod = 1e9 + 7;
signed main()
{
// Tima();
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >>n;
int a[n + 1];
for( int i = 1; i <= n; ++i )
cin >>a[i];
int ans = 0;
multiset< int >s;
for( int l = 1; l <= n; )
{
++ans;
int r = l;
auto j = s.upper_bound( a[l] );
while( r < n && a[r] <= a[r + 1] && (s.lower_bound(a[r + 1]) == j || s.upper_bound(a[r + 1]) == j) )
++r;
for( int _i = l; _i <= r; ++_i )
s.insert( a[_i] );
l = r + 1;
}
cout <<ans;
}
Compilation message (stderr)
# | 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... |