Submission #842419

# Submission time Handle Problem Language Result Execution time Memory
842419 2023-09-02T21:02:46 Z omeganot Closing Time (IOI23_closing) C++17
35 / 100
1000 ms 2097152 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
const int MOD = 1E9 + 7;
const int INF = 1E9; const ll INFLL = 1E18;

int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W) {
	vector<int> w(N);
	for(int i = 0; i + 1 < N; i++) {
		w[min(U[i], V[i])] = W[i];
	}
	vector<ll> wX(N); vector<ll> wY(N);
	for(int i = X + 1; i < N; i++) {
		wX[i] = wX[i - 1] + w[i - 1];
	}
	for(int i = X - 1; i >= 0; i--) {
		wX[i] = wX[i + 1] + w[i];
	}
	for(int i = Y + 1; i < N; i++) {
		wY[i] = wY[i - 1] + w[i - 1];
	}
	for(int i = Y - 1; i >= 0; i--) {
		wY[i] = wY[i + 1] + w[i];
	}
	vector<vector<array<ll, 9>>> dp(N, vector<array<ll, 9>>(2 * N + 1, {INFLL, INFLL, INFLL, INFLL, INFLL, INFLL, INFLL, INFLL, INFLL}));
	dp[0][0][0] = 0; dp[0][1][1] = wY[0]; 
	dp[0][1][3] = wX[0]; dp[0][2][4] = max(wX[0], wY[0]);
	for(int i = 1; i < N; i++) {
		for(int j = 0; j <= i * 2; j++) {
			if(!j) {
				dp[i][j][0] = 0;
			}
			dp[i][j + 1][1] = min(dp[i][j + 1][1], min((i <= Y ? dp[i - 1][j][0] : INFLL), dp[i - 1][j][1]) + wY[i]);
			if(i >= Y) {
				dp[i][j][2] = min({dp[i][j][2], dp[i - 1][j][1], dp[i - 1][j][2]});
				dp[i][j + 1][5] = min(dp[i][j + 1][5], min({(i <= X ? min(dp[i - 1][j][1], dp[i - 1][j][2]) : INFLL), dp[i - 1][j][4], dp[i - 1][j][5]}) + wX[i]);
			}
			dp[i][j + 1][3] = min(dp[i][j + 1][3], min((i <= X ? dp[i - 1][j][0] : INFLL), dp[i - 1][j][3]) + wX[i]);
			dp[i][j + 2][4] = min(dp[i][j + 2][4], min({(i <= min(X, Y) ? dp[i - 1][j][0] : INFLL), (i <= X ? dp[i - 1][j][1] : INFLL), (i <= Y ? dp[i - 1][j][3] : INFLL), dp[i - 1][j][4]}) + max(wX[i], wY[i]));
			if(i >= X) {
				dp[i][j][6] = min({dp[i][j][6], dp[i - 1][j][3], dp[i - 1][j][6]});
				dp[i][j + 1][7] = min(dp[i][j + 1][7], min({(i <= Y ? min(dp[i - 1][j][3], dp[i - 1][j][6]) : INFLL), dp[i - 1][j][4], dp[i - 1][j][7]}) + wY[i]);
				if(i >= Y) {
					dp[i][j][8] = min({dp[i][j][8], dp[i - 1][j][4], dp[i - 1][j][5], dp[i - 1][j][7], dp[i - 1][j][8]});
				}
			}
		}
	}
	for(int i = N * 2; i >= 2; i--) {
		if(min({dp[N - 1][i][4], dp[N - 1][i][5], dp[N - 1][i][7], dp[N - 1][i][8]}) <= K) {
			return i;
		}
	}
}

Compilation message

closing.cpp: In function 'int max_score(int, int, int, ll, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:10:17: warning: control reaches end of non-void function [-Wreturn-type]
   10 |  vector<int> w(N);
      |                 ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 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 1004 ms 2097152 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 Correct 0 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 1 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 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 1 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 2 ms 1628 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 1 ms 1380 KB Output is correct
15 Correct 1 ms 1628 KB Output is correct
16 Correct 1 ms 1628 KB Output is correct
17 Correct 1 ms 1804 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 17 ms 35676 KB Output is correct
20 Correct 15 ms 29788 KB Output is correct
21 Correct 16 ms 32876 KB Output is correct
22 Correct 17 ms 35420 KB Output is correct
23 Correct 16 ms 35676 KB Output is correct
24 Correct 17 ms 35732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 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 1 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 2 ms 1628 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 1 ms 1380 KB Output is correct
15 Correct 1 ms 1628 KB Output is correct
16 Correct 1 ms 1628 KB Output is correct
17 Correct 1 ms 1804 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 17 ms 35676 KB Output is correct
20 Correct 15 ms 29788 KB Output is correct
21 Correct 16 ms 32876 KB Output is correct
22 Correct 17 ms 35420 KB Output is correct
23 Correct 16 ms 35676 KB Output is correct
24 Correct 17 ms 35732 KB Output is correct
25 Correct 8 ms 824 KB Output is correct
26 Correct 554 ms 1275368 KB Output is correct
27 Correct 481 ms 1107256 KB Output is correct
28 Correct 497 ms 1114964 KB Output is correct
29 Correct 527 ms 1206692 KB Output is correct
30 Correct 492 ms 1091096 KB Output is correct
31 Correct 545 ms 1275420 KB Output is correct
32 Correct 569 ms 1275592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 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 0 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 0 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 0 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 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -