Submission #877778

# Submission time Handle Problem Language Result Execution time Memory
877778 2023-11-23T14:26:05 Z auslander Bigger segments (IZhO19_segments) C++17
0 / 100
0 ms 2392 KB
#include <algorithm>
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;
typedef long long ll;

const int N = 5e5;
ll arr[N], pref[N];

int main()
{
	ll i, j, n, m;
	cin >> n;
	for (i = 0; i < n; i++)
		cin >> arr[i];
	vector<ll>v;
	ll p = arr[0];
	ll k = 0;
	j = 0;
	ll res = 1;
	for (i = 1; i < n; i++)
	{
		k += arr[i];
		pref[j] = k;
		if (p <= k)
		{
			res++;
			vector<ll>::iterator it = lower_bound(v.begin(), v.end(), (k - p) / 2);
			p = k - pref[(it - v.begin())];
			k = 0;
			j = 0;
			v.erase(v.begin(), v.end());
		}
		else
		{
			v.push_back(k);
			j++;
		}
	}
	cout << res << endl;

	return 0;
}

Compilation message

segments.cpp: In function 'int main()':
segments.cpp:13:14: warning: unused variable 'm' [-Wunused-variable]
   13 |  ll i, j, n, m;
      |              ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -