Submission #955217

# Submission time Handle Problem Language Result Execution time Memory
955217 2024-03-29T17:28:42 Z 42kangaroo Closing Time (IOI23_closing) C++17
0 / 100
1000 ms 9932 KB
#include "closing.h"

#include <vector>

int max_score(int N, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
	using namespace std;
	if (X > Y) swap(X, Y);
	vector<int> distX(N), distY(N);
	distX[X] = 0;
	for (int i = X +1; i < N; ++i) {
		distX[i] = distX[i - 1] + W[i - 1];
	}
	for (int i = X - 1; i >= 0; --i) {
		distX[i] = distX[i + 1] + W[i];
	}
	distY[Y] = 0;
	for (int i = Y +1; i < N; ++i) {
		distY[i] = distY[i - 1] + W[i - 1];
	}
	for (int i = Y - 1; i >= 0; --i) {
		distY[i] = distY[i + 1] + W[i];
	}
	int ma = 0;
	for (int i = 0; i <= X; ++i) {
		int co = 0;
		for (int j = i; j < N; ++j) {
			co += distX[j];
			if (j >= X) {
				int act = i - j + 1;
				if (co > K) continue;
				else {
					int co2 = K - co;
					int lon = 0;
					int l = 0, r = Y;
					int cos = 0;
					for (int k = 0; k < Y; ++k) {
						if (i <= k && k <= j && distX[k] > distY[k]);
						else if (i <= k && k <= j) cos += distY[k] - distX[k];
						else cos += distY[k];
					}
					while (l < Y && r < N) {
						while (l < Y && r < N && cos > co2) {
							if (i <= l && l <= j && distX[l] > distY[l]);
							else if (i <= l && l <= j) cos -= distY[l] - distX[l];
							else cos -= distY[l];
							l++;
						}
						while (r < N && cos <= co2) {
							lon = max(lon, r - l + 1);
							r++;
							if (r == N) break;
							if (i <= r && r <= j && distX[r] > distY[r]);
							else if (i <= r && r <= j) cos += distY[r] - distX[r];
							else cos += distY[r];
						}
					}
					act += lon;
					ma = max(ma, act);
				}
			}
		}
	}
	return ma;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 9932 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -