답안 #635287

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
635287 2022-08-25T21:31:23 Z gromperen 메기 농장 (IOI22_fish) C++17
14 / 100
46 ms 8172 KB
#include "fish.h"

#include <bits/stdc++.h>

#define ll long long

using namespace std;

const int MAXN = 305;
ll pre[MAXN][10];
ll dp[MAXN][10][10];

long long max_weights(int N, int M, vector<int> X, vector<int> Y,
                      vector<int> W) {
	for (int i = 0; i < M; ++i) {
		pre[X[i]+1][Y[i]+1] += W[i];
	}
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= 9; ++j) {
			pre[i][j] += pre[i][j-1];
		}
	}

	ll ans = 0;
	for (int i = 2; i <= N; ++i) { for (int j = 0; j <= 9; ++j) {
	for (int k = 0; k <= 9; ++k) {
		if (i == 2) {
			if (j >= k) {
				dp[i][j][k] = pre[i-1][j] - pre[i-1][k];
			} else {
				dp[i][j][k] = pre[i][k] - pre[i][j];
			}
			ans = max(ans, dp[i][j][k]);
			continue;
		}
		for (int l = 0; l <= 9; ++l) {
			ll add = 0;
			if (l <= k && k <= j) {
				add = pre[i-1][j] - pre[i-1][k];  // 1 2 3
			} else if (l >= k && j >= l) {
				add = pre[i-1][j] - pre[i-1][l]; // 2 1 3
			} else if (l>=k && l>= j && j >= k) {
				add = 0; // 3 1 2
			} else if (k >= j) {
				add = pre[i][k] - pre[i][j]; // 1 3 2 and 2 3 1 and 3 2 1
			}
			dp[i][j][k] = max(dp[i][j][k], dp[i-1][k][l] + add);
		}
		ans = max(ans, dp[i][j][k]);
	}
	}
	}

	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 22 ms 4212 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 46 ms 8172 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Incorrect 1 ms 468 KB 1st lines differ - on the 1st token, expected: '299', found: '245'
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Incorrect 1 ms 468 KB 1st lines differ - on the 1st token, expected: '299', found: '245'
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 22 ms 4212 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -