답안 #523700

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
523700 2022-02-08T04:30:03 Z Sanzhar23 Money (IZhO17_money) C++14
0 / 100
1 ms 328 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long	
#define pb push_back
#define bug cout << "bug" << endl
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define pll pair <ll, ll> 
#define pii pair <int, int> 
#define triple pair <pair <ll, ll> , ll>  
#define ull unsigned long long
#define ld long double
#define pinode pair <node*, node*>

const ll INF = 9e18 + 5;
const ll inf = 1e9 + 5;
const ll N = 1e6 + 5;
const ll shift = 2e6;
const ll mod = 1e9 + 7;
const ll M = 255000 + 5;
const ll LOG = 21;
const ll sp = 263;
const ll block = 500;
const double eps = 1e-10;
	
int n, a[N];

int main(){
    speed;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	set <int> st1, st2;
	st1.insert(0);
	st1.insert(inf);
	st2.insert(0);
	st2.insert(-inf);
	int st = 1, ans = 0;
	while(st <= n){
		int nw = st;
		ans++;
		for(int i = st; i <= n; i++){
			if(i != st && a[i] < a[i - 1])
				break;
			if(i == st){
				nw = st + 1;
				continue;
			}
			int mn = a[st], mx = a[i];
			int f1 = *st1.lower_bound(mx), f2 = *st2.lower_bound(-mn);
			f2 *= -1;
			if(*st1.upper_bound(f2) != f1)
				break;
			if(mn >= f2 && mx <= f1){
				nw = i + 1;
				continue;
			}
			break;
		}
		for(int i = st; i <= nw - 1; i++){
			st1.insert(a[i]);
			st2.insert(-a[i]);
		}
		st = nw;
	}
	cout << ans << endl;
}
/*	
%I64d

6
3 5 1 2 4 6

		
		



%I64d
*/ 
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -