답안 #681815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681815 2023-01-14T13:25:50 Z Jarif_Rahman 메기 농장 (IOI22_fish) C++17
0 / 100
764 ms 2097152 KB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

ll max_weights(int n, int m, vector<int> X, vector<int> Y, vector<int> W){
    vector<vector<ll>> v(n, vector<ll>(n+1, 0));
    for(int i = 0; i < m; i++) v[X[i]][Y[i]+1]+=W[i];

    vector<vector<ll>> dp_up(n, vector<ll>(n+1, 0)), dp_down = dp_up,
    dtu2 = dp_up;
    vector<ll> dtu(n, 0);

    vector<vector<ll>> pref(n, vector<ll>(n+1, 0));
    for(int i = 0; i < n; i++) for(int j = 0; j <= n; j++){
        if(j) pref[i][j] = pref[i][j-1];
        pref[i][j]+=v[i][j];
    }

    for(int i = n-1; i >= 0; i--){
        for(int j = 0; j <= n; j++){
            if(i == n-1){
                dp_down[i][j] = 0;
                dp_up[i][j] = 0;
                continue;
            }

            dp_up[i][j]-=pref[i][j];
            dp_down[i][j]-=pref[i+1][n]-pref[i+1][j];
            dp_up[i][j] = max(dp_up[i][j], pref[i][n]-pref[i][j]+dp_down[i+1][n]);

            if(i+2 < n){
                dp_down[i][j] = max(dp_down[i][j], dtu2[i+2][j]+pref[i+1][j]);
                //dp_down[i][j] = max(dp_down[i][j], dtu[i+2]-pref[i+1][j]);
                ll s = 0;
                for(int k = j+1; k <= n; k++){
                    dp_down[i][j] = max(dp_down[i][j], s+dp_up[i+2][k]);
                }
                dp_down[i][j] = max(dp_down[i][j], pref[i+1][n]-pref[i+1][j]+dp_down[i+2][n]);
            }
        }

        if(i){
            ll mx = 0;
            for(int j = 0; j <= n; j++) mx = max(mx, pref[i-1][j]+dp_up[i][j]);
            fill(dp_up[i-1].begin(), dp_up[i-1].end(), mx);
            dtu[i] = mx;

            mx = 0;
            for(int j = 0; j <= n; j++) mx = max(mx, pref[i][n]-pref[i][j]+dp_down[i][j]);
            fill(dp_down[i-1].begin(), dp_down[i-1].end(), mx);

            for(int j = 0; j <= n; j++){
                if(j) dtu2[i][j] = dtu2[i][j-1];
                dtu2[i][j] = max(dtu2[i][j], dp_up[i][j]);
            }
        }
    }

    return max(*max_element(dp_up[0].begin(), dp_up[0].end()), *max_element(dp_down[0].begin(), dp_down[0].end()));
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 709 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 764 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 727 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 3 ms 1108 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '215227631108'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 3 ms 1108 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '215227631108'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 3 ms 1108 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '215227631108'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 727 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 709 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -