/*
(( '-""``""-' ))
)-__-_.._-__-(
/ --- (o _ o) --- \
\ .-* ( .0. ) *-. /
_'-. ,_ '=' _, .-'_
/ ;#'#'# - #'#'#; \
\_)) -----'#'----- ((_/
# --------- #
'# ------- #'
/..-'# ------- #'-.\
_\...-\'# -- #'/-.../_
((____)- '#' -(____))
art by - Vinni01 / luchi abi
cout << fixed << setprecision(6) << x;
freopen ( "sum.in", "r", stdin )
*/
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>
using namespace std ;
#define ll int
#define dd double
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define UseOFF ios_base::sync_with_stdio(0);cin.tie(0), cout.tie(0);
#define sz size
#define ins insert
#define new jweijofdg
const ll N = 2e5 + 111;
ll tt = 1 ;
ll a[ N ], b[ N ] ;
set < pair < ll, ll > > st ;
void solve()
{
ll n ;
cin >> n ;
ll ans = 0 ;
ll mn = 1e9, mx = 0 ;
for( int i = 1 ; i <= n ; i++ )
{
cin >> a[ i ] ;
mn = min( mn, a[ i ] ) ;
st.ins( { a[ i ], i } ) ;
}
mx = 1e9 ;
while( !st.empty() )
{
auto pos = st.begin()->ss ;
st.erase( st.begin() ) ;
ll mx2 = a[ pos ] ;
if( a[ pos ] < mx )
{
while( a[ pos ] < a[ pos + 1 ] && a[ pos + 1 ] <= mn )
{
pos++ ;
st.erase( { a[ pos ], pos } ) ;
mx2 = max( mx2, a[ pos ] ) ;
}
}
else
{
while( a[ pos ] < a[ pos + 1 ] )
{
st.erase( { a[ pos ], pos } ) ;
mx = a[ pos ] ;
pos++ ;
}
st.erase( { a[ pos ], pos } ) ;
mx = a[ pos ] ;
pos++ ;
}
if( mx == 1e9 )
{
mx = mx2 ;
}
ans++ ;
}
cout << ans ;
}
signed main()
{
//cin >> tt ;
while( tt-- )
{
solve() ;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |