Submission #680598

# Submission time Handle Problem Language Result Execution time Memory
680598 2023-01-11T10:36:21 Z anonimy Global Warming (NOI13_gw) C++14
40 / 40
246 ms 25452 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

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

	ll n;
	cin >> n;

	vector<pll> heights(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> heights[i].first;
		heights[i].second = i;
	}

	sort(heights.begin(), heights.end(), greater<pll>());
	vector<bool> used(n, false);

	ll ans = 0, curr = 0;
	for (ll i = 0; i < n; i++)
	{
		ll ind = heights[i].second;
		used[ind] = true;


		if ((ind == 0 || (!used[ind - 1])) && (ind == n - 1 || (!used[ind + 1])))
			curr++;
		if (ind && ind < n - 1 && used[ind - 1] && used[ind + 1])
			curr--;

		if (i == n - 1 || heights[i].first > heights[i + 1].first)
			ans = max(ans, curr);
	}

	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1900 KB Output is correct
2 Correct 18 ms 2132 KB Output is correct
3 Correct 16 ms 2152 KB Output is correct
4 Correct 16 ms 2144 KB Output is correct
5 Correct 18 ms 2152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1876 KB Output is correct
2 Correct 15 ms 2532 KB Output is correct
3 Correct 23 ms 2628 KB Output is correct
4 Correct 19 ms 2740 KB Output is correct
5 Correct 18 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 203 ms 15976 KB Output is correct
2 Correct 246 ms 25452 KB Output is correct
3 Correct 202 ms 25328 KB Output is correct
4 Correct 235 ms 25344 KB Output is correct
5 Correct 203 ms 24680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 235 ms 15964 KB Output is correct
2 Correct 246 ms 24664 KB Output is correct
3 Correct 211 ms 24664 KB Output is correct
4 Correct 200 ms 18944 KB Output is correct
5 Correct 192 ms 18940 KB Output is correct