Submission #52396

# Submission time Handle Problem Language Result Execution time Memory
52396 2018-06-25T18:23:57 Z MatheusLealV Money (IZhO17_money) C++17
0 / 100
1500 ms 536 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];

		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";
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 536 KB Output is correct
4 Execution timed out 1570 ms 536 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 536 KB Output is correct
4 Execution timed out 1570 ms 536 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 536 KB Output is correct
4 Execution timed out 1570 ms 536 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 536 KB Output is correct
4 Execution timed out 1570 ms 536 KB Time limit exceeded
5 Halted 0 ms 0 KB -