답안 #652685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
652685 2022-10-23T20:25:01 Z Lobo 메기 농장 (IOI22_fish) C++17
14 / 100
411 ms 14268 KB
#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

const int maxn = 330;
const int maxh = 12;
const int inf = 1e18+10;

int n, m, dp[maxn][maxh][maxh];
vector<pair<int,int>> fish[maxn];

long long max_weights(int32_t N, int32_t M, vector<int32_t> X, vector<int32_t> Y, vector<int32_t> W) {
    n = N;
    m = M;
    for(int i = 0; i < m; i++) {
        fish[X[i]+1].pb(mp(Y[i]+1,W[i]));
    }

    // dp[i][h1][h] = until i and with h[i-1] = h1 and h[i] = h

    // dp[0][0][0] = 0
    // dp[0][a][b] = -inf
    for(int i = 0; i <= maxh-1; i++) {
        for(int j = 0; j <= maxh-1; j++) {
            dp[0][i][j] = -inf;
        }
    }
    dp[0][0][0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int h1 = 0; h1 <= maxh-1; h1++) {
            for(int h = 0; h <= maxh-1; h++) {
                dp[i][h1][h] = 0;

                int plus10 = 0; // fishs that 1 catchs in 0
                for(auto aux : fish[i]) {
                    int y = aux.fr;
                    int w = aux.sc;
                    if(y > h && y <= h1) plus10+= w;
                }

                for(int h2 = 0; h2 <= maxh-1; h2++) {
                    int plus01 = 0; // fishs that 0 catchs in 1 and had not been caught by 2

                    for(auto aux : fish[i-1]) {
                        int y = aux.fr;
                        int w = aux.sc;
                        if(y > h1 && y <= h && y > h2) plus01+= w;
                    }
                    dp[i][h1][h] = max(dp[i][h1][h],dp[i-1][h2][h1]+plus01 + plus10);
                }
            }
        }
    }

    int ans = 0;
    for(int h = 0; h <= maxh-1; h++) {
        for(int h1 = 0; h1 <= maxh-1; h1++) {
            ans = max(ans,dp[n][h1][h]);
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 178 ms 7908 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 411 ms 14268 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 1132 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 284 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 10 ms 764 KB Output is correct
11 Correct 4 ms 468 KB Output is correct
12 Correct 5 ms 596 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 5 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 284 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 10 ms 764 KB Output is correct
11 Correct 4 ms 468 KB Output is correct
12 Correct 5 ms 596 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 5 ms 596 KB Output is correct
15 Incorrect 2 ms 596 KB 1st lines differ - on the 1st token, expected: '299', found: '11'
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 284 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 10 ms 764 KB Output is correct
11 Correct 4 ms 468 KB Output is correct
12 Correct 5 ms 596 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 5 ms 596 KB Output is correct
15 Incorrect 2 ms 596 KB 1st lines differ - on the 1st token, expected: '299', found: '11'
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 1132 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 178 ms 7908 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -