답안 #1079654

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079654 2024-08-28T20:09:30 Z ArthuroWich 메기 농장 (IOI22_fish) C++17
52 / 100
925 ms 2097152 KB
#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int pref[3005][3005];
int max_weights(int32_t N, int32_t M, vector<int32_t> X, vector<int32_t> Y, vector<int32_t> W) {
    int n = N, m = M;
    vector<vector<int>> c(n+1, vector<int>(n+1, 0));
    vector<vector<int>> dp(2, vector<int>(n+1, 0)), tdp(2, vector<int>(n+1, 0)); // 0 is increasing, 1 is decreasing, increasing can go to decreasing, decreasing cant go to increasing if next to eachother
    for (int i = 0; i < m; i++) {
        c[Y[i]+1][X[i]] = W[i];
        pref[Y[i]+1][X[i]] = W[i];
    }
    for (int j = 0; j < n; j++) {
        for (int i = 1; i <= n; i++) {
            pref[i][j] += pref[i-1][j];
        }
    }
    for (int j = 1; j <= n; j++) {
        int v = 0;
        for (int i = 0; i <= n; i++) {
            v = max(v, dp[0][i]-pref[i][j-1]);
            tdp[0][i] = max(v+pref[i][j-1], dp[1][0]);
        }
        v = 0;
        for (int i = n; i >= 0; i--) {
            v= max(v, max(dp[0][i], dp[1][i])+pref[i][j]);
            tdp[1][i] = v-pref[i][j];
        }
        swap(dp, tdp);
    }
    int ans = max(dp[0][0], dp[1][0]);
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 875 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 925 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 889 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 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 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 2 ms 3164 KB Output is correct
11 Correct 1 ms 1372 KB Output is correct
12 Correct 3 ms 2900 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 2 ms 3016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 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 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 2 ms 3164 KB Output is correct
11 Correct 1 ms 1372 KB Output is correct
12 Correct 3 ms 2900 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 2 ms 3016 KB Output is correct
15 Correct 2 ms 2908 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 11 ms 4700 KB Output is correct
18 Correct 10 ms 4804 KB Output is correct
19 Correct 10 ms 4700 KB Output is correct
20 Correct 10 ms 4700 KB Output is correct
21 Correct 10 ms 4700 KB Output is correct
22 Correct 20 ms 6484 KB Output is correct
23 Correct 3 ms 3416 KB Output is correct
24 Correct 13 ms 4184 KB Output is correct
25 Correct 3 ms 2908 KB Output is correct
26 Correct 4 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 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 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 2 ms 3164 KB Output is correct
11 Correct 1 ms 1372 KB Output is correct
12 Correct 3 ms 2900 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 2 ms 3016 KB Output is correct
15 Correct 2 ms 2908 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 11 ms 4700 KB Output is correct
18 Correct 10 ms 4804 KB Output is correct
19 Correct 10 ms 4700 KB Output is correct
20 Correct 10 ms 4700 KB Output is correct
21 Correct 10 ms 4700 KB Output is correct
22 Correct 20 ms 6484 KB Output is correct
23 Correct 3 ms 3416 KB Output is correct
24 Correct 13 ms 4184 KB Output is correct
25 Correct 3 ms 2908 KB Output is correct
26 Correct 4 ms 3416 KB Output is correct
27 Correct 211 ms 141672 KB Output is correct
28 Correct 47 ms 21328 KB Output is correct
29 Correct 243 ms 154196 KB Output is correct
30 Correct 245 ms 154604 KB Output is correct
31 Correct 231 ms 154196 KB Output is correct
32 Correct 64 ms 19300 KB Output is correct
33 Correct 223 ms 154224 KB Output is correct
34 Correct 244 ms 154192 KB Output is correct
35 Correct 211 ms 146260 KB Output is correct
36 Correct 263 ms 154192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 889 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 875 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -