Submission #344784

# Submission time Handle Problem Language Result Execution time Memory
344784 2021-01-06T14:32:18 Z SeDunion Money (IZhO17_money) C++17
0 / 100
1 ms 384 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 66;

int a[N], ans;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	set<int>S = {N};
	for (int i = 1 ; i <= n ; ++ i) cin >> a[i];
	{
		map<int,int> mp; for (int i = 1 ; i <= n ; ++ i) {
			assert(mp[a[i]]++ == 0);
		}
	}
	for (int i = 1 ; i <= n ; ++ i) {
		int j = i + 1;
		auto it = S.upper_bound(a[i]);
		while (j <= n && a[j] >= a[j - 1] && (a[j] == a[i] || S.lower_bound(a[i]) == it)) ++j;
		j--;
		S.insert(a[i]);
		S.insert(a[j]);
		ans++;
		i = j;
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -