답안 #747786

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
747786 2023-05-24T17:26:42 Z inventiontime 메기 농장 (IOI22_fish) C++17
0 / 100
966 ms 154372 KB
#include "fish.h"

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

#define pb push_back
#define re resize
#define ff first
#define ss second

#define all(x) (x).begin(), (x).end()
#define all1(x) (x).begin()+1, (x).end()
#define loop(i, n) for(int i = 0; i < n; i++)
#define loop1(i, n) for(int i = 1; i <= n; i++)

#define print(x) cout << #x << ": " << x << endl << flush

template<class T> bool ckmin(T&a, T b) { bool B = a > b; a = min(a, b); return B; }
template<class T> bool ckmax(T&a, T b) { bool B = a < b; a = max(a, b); return B; }

typedef long long ll;
typedef vector<int> vi;

const ll inf = 1e17;
const ll maxn = 3005;

ll fish[maxn][maxn];
ll pref[maxn][maxn];
ll dpi[maxn][maxn];
ll dpd[maxn][maxn];

ll max_weights(int n, int m, vi x, vi y, vi w) {

    loop(i, m) {
        x[i]++; y[i]++;
        fish[x[i]][y[i]] = w[i];
    }

    loop1(i, n) loop1(j, n)
        pref[i][j] = pref[i][j-1] + fish[i][j];

    loop(i, n+2) dpi[0][i] = -inf;
    loop(i, n+2) dpd[0][i] = -inf;
    dpd[0][1] = 0;
    //dpi[0][n] = 0;

    loop1(i, n) {
        dpi[i][n+1] = max(dpi[i-1][n], dpi[i-1][n+1]);
        loop1(j, n) {
            ckmax(dpi[i][j], dpd[i-1][1] + pref[i][j] - pref[i][0]);
            loop1(k, n) if(k <= j)
                ckmax(dpi[i][j], dpi[i-1][k] + pref[i][j] - pref[i][k]);
        }
        loop1(j, n) {
            ckmax(dpd[i][j], dpi[i-1][n+1] + pref[i][n] - pref[i][j-1]);
            loop1(k, n) if(k >= j)
                ckmax(dpd[i][j], dpd[i-1][k] + pref[i][k-1] - pref[i][j-1]);
        }
    }

    // cout << endl;

    // loop1(j, n) {
    //     loop1(i, n) cout << fish[i][j] << " ";
    //     cout << endl;
    // }

    // cout << endl;

    // loop1(j, n) {
    //     loop1(i, n) cout << dpi[i][j] << " ";
    //     cout << endl;
    // }

    // cout << endl;

    // loop1(j, n) {
    //     loop1(i, n) cout << dpd[i][j] << " ";
    //     cout << endl;
    // }

    // cout << endl;

    return max(dpd[n][1], dpi[n][n+1]);

}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 857 ms 149348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 889 ms 154372 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 966 ms 143824 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 0 ms 340 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 0 ms 340 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 0 ms 340 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 966 ms 143824 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 857 ms 149348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -