Submission #518790

# Submission time Handle Problem Language Result Execution time Memory
518790 2022-01-24T16:05:25 Z sliviu Rice Hub (IOI11_ricehub) C++17
0 / 100
5 ms 580 KB
#include <bits/stdc++.h>
#include "ricehub.h"

using namespace std;

int besthub(int n, int L, int a[], long long cmax) {
	long long curcost = 0;
	int sol, cursol = 1;
	queue<int> l, r;
	l.emplace(0);
	for (int i = 1; i < n; ++i)
		r.emplace(i);
	while (!r.empty() && a[r.front()] - a[0] <= cmax - curcost) {
		++cursol, curcost += a[r.front()] - a[0];
		r.pop();
	}
	sol = cursol;
	for (int i = 1; i < n; ++i) {
		curcost += 1LL * (a[i] - a[i - 1]) * l.size();
		curcost -= 1LL * (a[i] - a[i - 1]) * (cursol - l.size());
		while (!l.empty() && curcost > cmax) {
			curcost -= a[i] - a[l.front()];
			--cursol;
			l.pop();
		}
		while (!r.empty() && a[r.front()] - a[i] <= cmax - curcost) {
			++cursol;
			curcost += a[r.front()] - a[i];
			r.pop();
		}
		while (!r.empty() && a[r.front()] - a[i] - (l.empty() ? 0 : a[i] - a[l.front()]) <= cmax - curcost) {
			cursol += l.empty();
			curcost += a[r.front()] - a[i] - (l.empty() ? 0 : a[i] - a[l.front()]);
			if (!l.empty())
				l.pop();
			r.pop();
		}
		l.emplace(i);
		sol = max(sol, cursol);
	}
	return sol;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Incorrect 1 ms 312 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Incorrect 0 ms 208 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 580 KB Output isn't correct
2 Halted 0 ms 0 KB -