Submission #957639

# Submission time Handle Problem Language Result Execution time Memory
957639 2024-04-04T06:41:09 Z 42kangaroo Closing Time (IOI23_closing) C++17
21 / 100
1000 ms 8412 KB
#include "closing.h"

#include <vector>

#define ll long long

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<ll> 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) {
		ll co = 0;
		for (int j = i; j < N; ++j) {
			co += distX[j];
			if (j >= X) {
				int act = j - i + 1;
				if (co > K) continue;
				else {
					ll co2 = K - co;
					int lon = 0;
					int l = 0, r = Y;
					ll 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 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1012 ms 8412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 25 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 20 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 25 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 20 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 5 ms 344 KB Output is correct
26 Execution timed out 1061 ms 348 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -