답안 #626564

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
626564 2022-08-11T14:38:17 Z Kaitokid 메기 농장 (IOI22_fish) C++17
35 / 100
1000 ms 213072 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int mx;
ll dp[3009][3009][2];
ll sum[3009][3009];
ll go(int x,int lst,int u)
{
    if(x==mx)return 0;
    if(dp[x][lst][u]!=-1)return dp[x][lst][u];
    for(int i=0;i<=mx;i++)
    {
        ll d=0;
        if(u==0 && i>lst) d=sum[x-1][i]-sum[x-1][lst];
        dp[x][lst][u]=max(dp[x][lst][u],d+go(x+1,i,0));
        if(i<lst)d+=sum[x][lst]-sum[x][i];
        dp[x][lst][u]=max(dp[x][lst][u],d+go(x+1,i,1));
    }
    return dp[x][lst][u];
}
ll max_weights(int N,int M,vector<int>X,vector<int>Y,vector<int>W)
{
    mx=N;
    for(int i=0;i<M;i++)sum[X[i]][Y[i]+1]+=W[i];
    for(int i=0;i<N;i++)
        for(int j=1;j<=N;j++)sum[i][j]+=sum[i][j-1];
    memset(dp,-1,sizeof dp);
    ll ans=0;
    for(int i=0;i<=N;i++)
       ans=max(ans,go(1,i,0));
       return ans;
}

Compilation message

fish.cpp: In function 'll max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:29:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   29 |     for(int i=0;i<=N;i++)
      |     ^~~
fish.cpp:31:8: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   31 |        return ans;
      |        ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1098 ms 118548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 142028 KB Output is correct
2 Execution timed out 1095 ms 118856 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1094 ms 106868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 141924 KB Output is correct
2 Correct 53 ms 142028 KB Output is correct
3 Correct 65 ms 141996 KB Output is correct
4 Correct 60 ms 141952 KB Output is correct
5 Correct 55 ms 142028 KB Output is correct
6 Correct 54 ms 141976 KB Output is correct
7 Correct 54 ms 141976 KB Output is correct
8 Correct 57 ms 142020 KB Output is correct
9 Correct 90 ms 142796 KB Output is correct
10 Correct 296 ms 143924 KB Output is correct
11 Correct 84 ms 142776 KB Output is correct
12 Correct 301 ms 143996 KB Output is correct
13 Correct 58 ms 142296 KB Output is correct
14 Correct 297 ms 143988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 141924 KB Output is correct
2 Correct 53 ms 142028 KB Output is correct
3 Correct 65 ms 141996 KB Output is correct
4 Correct 60 ms 141952 KB Output is correct
5 Correct 55 ms 142028 KB Output is correct
6 Correct 54 ms 141976 KB Output is correct
7 Correct 54 ms 141976 KB Output is correct
8 Correct 57 ms 142020 KB Output is correct
9 Correct 90 ms 142796 KB Output is correct
10 Correct 296 ms 143924 KB Output is correct
11 Correct 84 ms 142776 KB Output is correct
12 Correct 301 ms 143996 KB Output is correct
13 Correct 58 ms 142296 KB Output is correct
14 Correct 297 ms 143988 KB Output is correct
15 Correct 293 ms 143976 KB Output is correct
16 Correct 65 ms 142440 KB Output is correct
17 Correct 308 ms 145064 KB Output is correct
18 Correct 300 ms 145036 KB Output is correct
19 Correct 306 ms 145036 KB Output is correct
20 Correct 307 ms 145040 KB Output is correct
21 Correct 310 ms 145040 KB Output is correct
22 Correct 323 ms 145988 KB Output is correct
23 Correct 290 ms 144076 KB Output is correct
24 Correct 313 ms 144676 KB Output is correct
25 Correct 307 ms 144000 KB Output is correct
26 Correct 305 ms 144168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 141924 KB Output is correct
2 Correct 53 ms 142028 KB Output is correct
3 Correct 65 ms 141996 KB Output is correct
4 Correct 60 ms 141952 KB Output is correct
5 Correct 55 ms 142028 KB Output is correct
6 Correct 54 ms 141976 KB Output is correct
7 Correct 54 ms 141976 KB Output is correct
8 Correct 57 ms 142020 KB Output is correct
9 Correct 90 ms 142796 KB Output is correct
10 Correct 296 ms 143924 KB Output is correct
11 Correct 84 ms 142776 KB Output is correct
12 Correct 301 ms 143996 KB Output is correct
13 Correct 58 ms 142296 KB Output is correct
14 Correct 297 ms 143988 KB Output is correct
15 Correct 293 ms 143976 KB Output is correct
16 Correct 65 ms 142440 KB Output is correct
17 Correct 308 ms 145064 KB Output is correct
18 Correct 300 ms 145036 KB Output is correct
19 Correct 306 ms 145036 KB Output is correct
20 Correct 307 ms 145040 KB Output is correct
21 Correct 310 ms 145040 KB Output is correct
22 Correct 323 ms 145988 KB Output is correct
23 Correct 290 ms 144076 KB Output is correct
24 Correct 313 ms 144676 KB Output is correct
25 Correct 307 ms 144000 KB Output is correct
26 Correct 305 ms 144168 KB Output is correct
27 Execution timed out 1074 ms 213072 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1094 ms 106868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1098 ms 118548 KB Time limit exceeded
2 Halted 0 ms 0 KB -