답안 #52395

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
52395 2018-06-25T18:23:16 Z MatheusLealV Money (IZhO17_money) C++17
0 / 100
1500 ms 600 KB
#include <bits/stdc++.h>
#define N 1000050
using namespace std;

int bit[N], v[N], n, ans;

void upd(int x, int v)
{
	for(int i = x; i < N; i += (i&-i)) bit[i] += v;
}

int query(int x)
{
	int sum = 0;

	for(int i = x; i > 0; i -= (i&-i)) sum += bit[i];

	return sum;
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);

	cin>>n;

	for(int i = 1; i <= n; i++) cin>>v[i];

	for(int i = 1; i <= n; i++)
	{
		int st = i, ant = v[i];

		ans ++;

		while(i <= n and v[i] >= ant)
		{
			if(query(v[i]) - query(v[st] - 1)) break;

			ant = v[i];

			i ++;
		}

		for(int j = st; j < i; j++) upd(v[j], 1);

		i --;
	}

	cout<<ans<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Execution timed out 1552 ms 600 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Execution timed out 1552 ms 600 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Execution timed out 1552 ms 600 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Execution timed out 1552 ms 600 KB Time limit exceeded
5 Halted 0 ms 0 KB -