답안 #842414

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
842414 2023-09-02T20:54:03 Z omeganot 봉쇄 시간 (IOI23_closing) C++17
21 / 100
1000 ms 1586936 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] = 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);
      |                 ^
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1056 ms 1586936 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 600 KB Output is correct
8 Correct 1 ms 856 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 600 KB Output is correct
8 Correct 1 ms 856 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 1628 KB Output is correct
13 Correct 1 ms 1660 KB Output is correct
14 Correct 1 ms 1368 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 1628 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 17 ms 35572 KB Output is correct
20 Correct 15 ms 29744 KB Output is correct
21 Correct 18 ms 32696 KB Output is correct
22 Correct 20 ms 35428 KB Output is correct
23 Correct 17 ms 35676 KB Output is correct
24 Correct 19 ms 35640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 600 KB Output is correct
8 Correct 1 ms 856 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 1628 KB Output is correct
13 Correct 1 ms 1660 KB Output is correct
14 Correct 1 ms 1368 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 1628 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 17 ms 35572 KB Output is correct
20 Correct 15 ms 29744 KB Output is correct
21 Correct 18 ms 32696 KB Output is correct
22 Correct 20 ms 35428 KB Output is correct
23 Correct 17 ms 35676 KB Output is correct
24 Correct 19 ms 35640 KB Output is correct
25 Incorrect 7 ms 1056 KB 15th lines differ - on the 1st token, expected: '80', found: '79'
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -