Submission #149261

# Submission time Handle Problem Language Result Execution time Memory
149261 2019-09-01T06:05:01 Z bitKOIn(#3612, gs15120, phsongys) Crosses on the Grid (FXCUP4_cross) C++17
100 / 100
200 ms 7656 KB
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdio>

int st[524288];

long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
	int N = I.size();
	int NN = 1;
	for (int t = N - 1; t; t >>= 1) NN <<= 1;
	std::vector<std::pair<int, int>> T;
	std::vector<int> CC(O);
	T.reserve(N);
	for (int i = 0; i < N; ++i) T.push_back({-I[i], O[i]});
	std::sort(T.begin(), T.end());
	std::sort(CC.begin(), CC.end());
	CC.erase(std::unique(CC.begin(), CC.end()), CC.end());
	long long ans = 0;

	for (int i = 0; i < N; ++i) {
		int ii = std::lower_bound(CC.begin(), CC.end(), T[i].second) - CC.begin();
		++st[NN + ii];
		for (int p = NN + ii; (p >>= 1); ) st[p] = st[p << 1] + st[p << 1 | 1];
		if (i >= K - 1) {
			int rem = i - K + 1;
			int p = 1;
			for (; p < NN; )
			{
				if (st[p << 1] <= rem) rem -= st[p << 1], p = p << 1 | 1;
				else p <<= 1;
			}
			if (st[p] <= rem) ++p;
			long long ov = CC[p - NN];
			long long dv = ov + T[i].first;
			ans = std::max(ans, ov * ov - dv * dv);
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 472 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 15 ms 768 KB Output is correct
6 Correct 185 ms 7656 KB Output is correct
7 Correct 196 ms 7528 KB Output is correct
8 Correct 200 ms 7636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 472 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 15 ms 768 KB Output is correct
6 Correct 185 ms 7656 KB Output is correct
7 Correct 196 ms 7528 KB Output is correct
8 Correct 200 ms 7636 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 16 ms 896 KB Output is correct
13 Correct 93 ms 4100 KB Output is correct
14 Correct 185 ms 7624 KB Output is correct
15 Correct 187 ms 7532 KB Output is correct
16 Correct 189 ms 7608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 472 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 15 ms 768 KB Output is correct
6 Correct 185 ms 7656 KB Output is correct
7 Correct 196 ms 7528 KB Output is correct
8 Correct 200 ms 7636 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 16 ms 896 KB Output is correct
13 Correct 93 ms 4100 KB Output is correct
14 Correct 185 ms 7624 KB Output is correct
15 Correct 187 ms 7532 KB Output is correct
16 Correct 189 ms 7608 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 7 ms 384 KB Output is correct
19 Correct 15 ms 896 KB Output is correct
20 Correct 89 ms 4080 KB Output is correct
21 Correct 144 ms 6124 KB Output is correct
22 Correct 178 ms 7532 KB Output is correct
23 Correct 178 ms 7556 KB Output is correct
24 Correct 179 ms 7656 KB Output is correct
25 Correct 178 ms 7656 KB Output is correct
26 Correct 168 ms 7524 KB Output is correct