답안 #1069438

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1069438 2024-08-21T22:41:17 Z MarwenElarbi 메기 농장 (IOI22_fish) C++17
35 / 100
1000 ms 2097152 KB
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
const int nax = 3e3+5;
vector<long long> tab[nax];
 
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
                          std::vector<int> W) {
    int n=N;
    int m=M;
    int grid[n+1][n+1];
    memset(grid,0,sizeof grid);
    long long pre[n+1][n+1];
    memset(pre,0,sizeof pre);
    for (int i = 0; i < m; ++i)
    {
        grid[X[i]][Y[i]+1]+=W[i];
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j <= n; ++j)
        {
            pre[i][j]=(j ? pre[i][j-1] : 0)+grid[i][j];
        }
    }
    long long dp[n+1][n+1][2];
    memset(dp,0,sizeof dp);
    long long ans=0;
    for (int i = 1; i < n; ++i)
    {
        for (int j = 0; j <= n; ++j)
        {
            for (int k = 0; k <= n; ++k)
            {
                if(k<j){
                    dp[i][j][1]=max(dp[i][j][1],dp[i-1][k][1]+pre[i-1][j]-pre[i-1][k]);
                    dp[i][j][1]=max(dp[i][j][1],dp[i-1][0][0]);
                }else if(k>j){
                    dp[i][j][0]=max(dp[i][j][0],dp[i-1][k][1]+pre[i][k]-pre[i][j]);
                    dp[i][j][0]=max(dp[i][j][0],dp[i-1][k][0]+pre[i][k]-pre[i][j]);
                }else if (j==0){
                    dp[i][j][0]=max({dp[i][j][0],dp[i-1][j][0],dp[i-1][j][1]});
                    dp[i][j][1]=max({dp[i][j][1],dp[i-1][j][0],dp[i-1][j][1]});
                }/*else{
                    dp[i][j][0]=max({dp[i][j][0],dp[i-1][j][0],dp[i-1][j][1]});
                    dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][1]);
                }*/
                ans=max({ans,dp[i][j][0],dp[i][j][1]});
            }
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1042 ms 2097152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 1068 ms 2097152 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1054 ms 2097152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 8 ms 1144 KB Output is correct
10 Correct 55 ms 2908 KB Output is correct
11 Correct 9 ms 1116 KB Output is correct
12 Correct 55 ms 3004 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 68 ms 3000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 8 ms 1144 KB Output is correct
10 Correct 55 ms 2908 KB Output is correct
11 Correct 9 ms 1116 KB Output is correct
12 Correct 55 ms 3004 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 68 ms 3000 KB Output is correct
15 Correct 55 ms 2968 KB Output is correct
16 Correct 2 ms 600 KB Output is correct
17 Correct 70 ms 4700 KB Output is correct
18 Correct 63 ms 4952 KB Output is correct
19 Correct 62 ms 4788 KB Output is correct
20 Correct 66 ms 4696 KB Output is correct
21 Correct 63 ms 4696 KB Output is correct
22 Correct 71 ms 6404 KB Output is correct
23 Correct 58 ms 3164 KB Output is correct
24 Correct 67 ms 4164 KB Output is correct
25 Correct 54 ms 2908 KB Output is correct
26 Correct 55 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 8 ms 1144 KB Output is correct
10 Correct 55 ms 2908 KB Output is correct
11 Correct 9 ms 1116 KB Output is correct
12 Correct 55 ms 3004 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 68 ms 3000 KB Output is correct
15 Correct 55 ms 2968 KB Output is correct
16 Correct 2 ms 600 KB Output is correct
17 Correct 70 ms 4700 KB Output is correct
18 Correct 63 ms 4952 KB Output is correct
19 Correct 62 ms 4788 KB Output is correct
20 Correct 66 ms 4696 KB Output is correct
21 Correct 63 ms 4696 KB Output is correct
22 Correct 71 ms 6404 KB Output is correct
23 Correct 58 ms 3164 KB Output is correct
24 Correct 67 ms 4164 KB Output is correct
25 Correct 54 ms 2908 KB Output is correct
26 Correct 55 ms 3164 KB Output is correct
27 Execution timed out 1057 ms 247276 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1054 ms 2097152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1042 ms 2097152 KB Time limit exceeded
2 Halted 0 ms 0 KB -