Submission #52397

# Submission time Handle Problem Language Result Execution time Memory
52397 2018-06-25T18:32:14 Z MatheusLealV Money (IZhO17_money) C++17
0 / 100
3 ms 488 KB
#include <bits/stdc++.h>
#define N 1000050
using namespace std;

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

void upd(int x, int v)
{
	x += 2;

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

int query(int x)
{
	x += 2;

	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], entrou = false;

		ans ++;

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

			entrou = true;

			ant = v[i];

			i ++;
		}

		if(!entrou) i ++;

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

		i --;
	}

	cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Incorrect 2 ms 488 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Incorrect 2 ms 488 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Incorrect 2 ms 488 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Incorrect 2 ms 488 KB Output isn't correct
5 Halted 0 ms 0 KB -