Submission #36379

# Submission time Handle Problem Language Result Execution time Memory
36379 2017-12-08T13:21:35 Z cheater2k Money (IZhO17_money) C++14
0 / 100
0 ms 9988 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1000005;

int n, a[N];
int T[N];
int ans;

void upd(int x) { for (; x < N; x += x & -x) T[x]++; }
int get(int x) { int res = 0; for (; x > 0; x -= x & -x) res += T[x]; return res; }

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];

	ans = 1;
	upd(a[1]);
	for (int i = 2; i <= n; ++i) {
		if (a[i] < a[i-1] || get(a[i] - 1) - get(a[i-1]) != 0) 
			++ans; // can't put a[i] and a[i-1] in a subsegment
		upd(a[i]);
		//cerr << i << ' ' << ans << endl;
	}

	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9988 KB Output is correct
2 Correct 0 ms 9988 KB Output is correct
3 Correct 0 ms 9988 KB Output is correct
4 Correct 0 ms 9988 KB Output is correct
5 Correct 0 ms 9988 KB Output is correct
6 Correct 0 ms 9988 KB Output is correct
7 Incorrect 0 ms 9988 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9988 KB Output is correct
2 Correct 0 ms 9988 KB Output is correct
3 Correct 0 ms 9988 KB Output is correct
4 Correct 0 ms 9988 KB Output is correct
5 Correct 0 ms 9988 KB Output is correct
6 Correct 0 ms 9988 KB Output is correct
7 Incorrect 0 ms 9988 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9988 KB Output is correct
2 Correct 0 ms 9988 KB Output is correct
3 Correct 0 ms 9988 KB Output is correct
4 Correct 0 ms 9988 KB Output is correct
5 Correct 0 ms 9988 KB Output is correct
6 Correct 0 ms 9988 KB Output is correct
7 Incorrect 0 ms 9988 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9988 KB Output is correct
2 Correct 0 ms 9988 KB Output is correct
3 Correct 0 ms 9988 KB Output is correct
4 Correct 0 ms 9988 KB Output is correct
5 Correct 0 ms 9988 KB Output is correct
6 Correct 0 ms 9988 KB Output is correct
7 Incorrect 0 ms 9988 KB Output isn't correct
8 Halted 0 ms 0 KB -