답안 #523710

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
523710 2022-02-08T04:47:12 Z Sanzhar23 Money (IZhO17_money) C++14
0 / 100
0 ms 332 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], t[N];

void upd(int pos, int val){
	while(pos <= N - 5){
		t[pos] += val;
		pos = (pos | (pos + 1));
	}
}

int get(int pos){
	int res = 0;
	while(pos >= 0){
		res += t[pos];
		pos = (pos & (pos + 1)) - 1;
	}
	return res;
}

int sum(int l, int r){
	return get(r) - get(l - 1);
}

int main(){
    speed;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int st = 1, ans = 0;
	while(st <= n){
		int nw = st + 1;
		ans++;
		for(int i = st + 1; i <= n; i++){
			if(a[i] >= a[i - 1] && sum(a[st], a[i]) == 0){
				nw = i + 1;
				continue;
			}
			break;
		}
		for(int i = st; i <= nw - 1; i++)
			upd(a[i], 1);
		st = nw;
	}
	cout << ans << endl;
}
/*	
%I64d

6
3 5 1 2 4 6

		
		



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