답안 #829300

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829300 2023-08-18T08:30:06 Z tolbi 메기 농장 (IOI22_fish) C++17
52 / 100
662 ms 508384 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#include "fish.h"
ll dp[3001][3001][3];
int grid[3001][3001];
int N;
long long f(int x, int y, int flag){
    if (dp[x][y][flag]!=-1) return dp[x][y][flag];
    if (flag==1){
        dp[x][y][flag]=0;
        if (y<N){
            ll crr = 0;
            if (x>0) crr = grid[x-1][y];
            dp[x][y][flag]=crr+f(x,y+1,1);
        }
        if (x+1<N){
            dp[x][y][flag]=max(dp[x][y][flag],f(x+1,y,1));
            dp[x][y][flag]=max(dp[x][y][flag],f(x+1,y,0));
        }
    }
    else if (flag==0){
        dp[x][y][flag]=0;
        if (y-1>=0){
            dp[x][y][flag]=grid[x][y-1]+f(x,y-1,0);
        }
        if (x+1<N){
            dp[x][y][flag]=max(dp[x][y][flag],f(x+1,y,0));
            if (y==0){
                dp[x][y][flag]=max(dp[x][y][flag],f(x+1,y,2));
            }
        }
    }
    else {
        dp[x][y][flag]=0;
        if (y<N){
            dp[x][y][flag]=f(x,y+1,2);
        }
        if (x+1<N){
            dp[x][y][flag]=max(dp[x][y][flag],f(x+1,y,1));
            dp[x][y][flag]=max(dp[x][y][flag],f(x+1,y,0));
        }
    }
    if (flag!=0 && x+2<N){
        dp[x][y][flag]=max(dp[x][y][flag],f(x+2,0,1));
    }
    return dp[x][y][flag];
};

long long max_weights(int _N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
    N=_N;
    for (int i = 0; i < N+1; i++){
        for (int j = 0; j < N+1; j++){
            grid[i][j]=0;
            dp[i][j][0]=dp[i][j][1]=dp[i][j][2]=-1;
        }
    }
    for (int i = 0; i < M; ++i)
    {
        grid[X[i]][Y[i]]=W[i];
    }
    //0 decreasing
    //1 increasing
    //2 increasing, \
    but forbidden to profit from back
    return f(0,0,2);
}

Compilation message

fish.cpp:64:5: warning: multi-line comment [-Wcomment]
   64 |     //2 increasing, \
      |     ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 638 ms 504540 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 662 ms 508384 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 596 ms 500732 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 2132 KB Output is correct
10 Correct 6 ms 5396 KB Output is correct
11 Correct 2 ms 2188 KB Output is correct
12 Correct 6 ms 5364 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 6 ms 5332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 2132 KB Output is correct
10 Correct 6 ms 5396 KB Output is correct
11 Correct 2 ms 2188 KB Output is correct
12 Correct 6 ms 5364 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 6 ms 5332 KB Output is correct
15 Correct 6 ms 5344 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 18 ms 6364 KB Output is correct
18 Correct 15 ms 6348 KB Output is correct
19 Correct 15 ms 6356 KB Output is correct
20 Correct 15 ms 6356 KB Output is correct
21 Correct 15 ms 6356 KB Output is correct
22 Correct 25 ms 7392 KB Output is correct
23 Correct 9 ms 5544 KB Output is correct
24 Correct 13 ms 5972 KB Output is correct
25 Correct 6 ms 5364 KB Output is correct
26 Correct 7 ms 5460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 2132 KB Output is correct
10 Correct 6 ms 5396 KB Output is correct
11 Correct 2 ms 2188 KB Output is correct
12 Correct 6 ms 5364 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 6 ms 5332 KB Output is correct
15 Correct 6 ms 5344 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 18 ms 6364 KB Output is correct
18 Correct 15 ms 6348 KB Output is correct
19 Correct 15 ms 6356 KB Output is correct
20 Correct 15 ms 6356 KB Output is correct
21 Correct 15 ms 6356 KB Output is correct
22 Correct 25 ms 7392 KB Output is correct
23 Correct 9 ms 5544 KB Output is correct
24 Correct 13 ms 5972 KB Output is correct
25 Correct 6 ms 5364 KB Output is correct
26 Correct 7 ms 5460 KB Output is correct
27 Correct 429 ms 248032 KB Output is correct
28 Correct 80 ms 30864 KB Output is correct
29 Correct 520 ms 260620 KB Output is correct
30 Correct 514 ms 260640 KB Output is correct
31 Correct 543 ms 260640 KB Output is correct
32 Correct 84 ms 25328 KB Output is correct
33 Correct 501 ms 260592 KB Output is correct
34 Correct 526 ms 260632 KB Output is correct
35 Correct 458 ms 252716 KB Output is correct
36 Correct 501 ms 260580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 596 ms 500732 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 638 ms 504540 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -