답안 #834640

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
834640 2023-08-22T16:21:06 Z tengiz05 메기 농장 (IOI22_fish) C++17
0 / 100
773 ms 439744 KB
#include "fish.h"

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

constexpr int N = 3000;

i64 dp[N + 1][N + 1][2];
i64 pre[N + 1][N + 1];

void chmax(i64 &a, i64 b) {
    if (a < b) {
        a = b;
    }
}

long long max_weights(int n, int m, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W) {
    for (int i = 0; i < m; i++) {
        pre[X[i]][Y[i] + 1] += W[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            pre[i][j + 1] += pre[i][j];
        }
    }
    
    memset(dp, 190, sizeof dp);
    
    for (int i = 0; i <= n; i++) {
        dp[0][i][0] = dp[0][i][1] = 0;
    }
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = j; k <= n; k++) {
                chmax(dp[i][k][0], dp[i - 1][j][0] + pre[i - 1][k] - pre[i - 1][j]);
            }
            for (int k = j; k >= 0; k--) {
                chmax(dp[i][k][1], dp[i - 1][j][1] + pre[i][j] - pre[i][k]);
            }
            if (i >= 2) {
                for (int k = 0; k <= n; k++) {
                    chmax(dp[i][k][0], dp[i - 2][j][1] + pre[i - 1][max(j, k)] - pre[i - 1][min(j, k)]);
                }
            }
        }
        for (int j = 0; j <= n; j++) {
            chmax(dp[i][j][1], dp[i][j][0]);
        }
    }
    
    i64 ans = 0;
    for (int i = 0; i <= n; i++) {
        ans = max(ans, dp[n - 1][i][1]);
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 730 ms 434388 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 141264 KB Output is correct
2 Runtime error 773 ms 439744 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 765 ms 429192 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 141288 KB Output is correct
2 Correct 48 ms 141204 KB Output is correct
3 Correct 54 ms 141228 KB Output is correct
4 Correct 43 ms 141236 KB Output is correct
5 Correct 45 ms 141168 KB Output is correct
6 Correct 50 ms 141276 KB Output is correct
7 Correct 48 ms 141176 KB Output is correct
8 Correct 47 ms 141192 KB Output is correct
9 Incorrect 63 ms 142036 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 141288 KB Output is correct
2 Correct 48 ms 141204 KB Output is correct
3 Correct 54 ms 141228 KB Output is correct
4 Correct 43 ms 141236 KB Output is correct
5 Correct 45 ms 141168 KB Output is correct
6 Correct 50 ms 141276 KB Output is correct
7 Correct 48 ms 141176 KB Output is correct
8 Correct 47 ms 141192 KB Output is correct
9 Incorrect 63 ms 142036 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 141288 KB Output is correct
2 Correct 48 ms 141204 KB Output is correct
3 Correct 54 ms 141228 KB Output is correct
4 Correct 43 ms 141236 KB Output is correct
5 Correct 45 ms 141168 KB Output is correct
6 Correct 50 ms 141276 KB Output is correct
7 Correct 48 ms 141176 KB Output is correct
8 Correct 47 ms 141192 KB Output is correct
9 Incorrect 63 ms 142036 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 765 ms 429192 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 730 ms 434388 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -