답안 #1068433

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1068433 2024-08-21T09:51:47 Z Unforgettablepl 메기 농장 (IOI22_fish) C++17
0 / 100
1000 ms 1746100 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;

long long max_weights(int N, int M,vector<int> X,vector<int> Y,
                      vector<int> W){
    vector DP(N+1,vector(N+1,vector(2,0ll)));
    vector pref(N+2,vector(N+1,0ll));
    vector transition1(N+1,vector(N+1,0ll));
    vector transition2(N+1,vector(N+1,0ll));
    vector transition3(N+1,vector(N+1,0ll));
    vector transition4(N+1,vector(N+1,0ll));
    for(int i=0;i<M;i++) {
        pref[X[i]+1][Y[i]+1]=W[i];
    }
    for(int i=1;i<=N;i++)for(int j=1;j<=N;j++)pref[i][j]+=pref[i][j-1];
    for(int i=2;i<=N;i++) {
        for(int j=0;j<=N;j++) {
            DP[i][j][1]=max(DP[i][j][1],-pref[i][j]+transition1[i-1][j]);
            if(i>2) {
                for(int x=0;x<=N;x++) {
                    DP[i][j][0]=max(DP[i][j][0],pref[i-1][max(x,j)]+max(DP[i-2][x][0],DP[i-2][x][1]));
                }
            }
            for(int x=0;x<=j;x++) {
                DP[i][j][0]=max(DP[i][j][0],pref[i-1][j]-pref[i-1][x]+DP[i-1][x][0]);
            }
            transition1[i][j]=pref[i+1][j]+max(DP[i][j][0],DP[i][j][1]);
        }
        for(int j=N-1;j>=0;j--)transition1[i][j]=max(transition1[i][j],transition1[i][j+1]);
    }
    long long ans = 0;
    for(int j=0;j<=N;j++)ans=max(ans,DP[N][j][0]);
    for(int j=0;j<=N;j++)ans=max(ans,DP[N][j][1]);
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1135 ms 1746100 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Execution timed out 1098 ms 1626452 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1136 ms 1741664 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 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 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 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 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 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1136 ms 1741664 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1135 ms 1746100 KB Time limit exceeded
2 Halted 0 ms 0 KB -