답안 #1056919

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1056919 2024-08-13T12:25:06 Z noyancanturk 메기 농장 (IOI22_fish) C++17
52 / 100
534 ms 465780 KB
#include "fish.h"

#include<bits/stdc++.h>
using namespace std;

using lint=long long;

const int lim=3e3+100;

int n,m;
lint dp[lim][lim],up[lim][lim];
lint pref[lim][lim];
lint p(int i,int l,int r){
  if(r<l)return 0;
  if(l){
    //cerr<<pref[i][r]<<" "<<pref[i][l-1]<<" "<<pref[i][r]-pref[i][l-1]<<"\n";
    return pref[i][r]-pref[i][l-1];
  }
  return pref[i][r];
}

lint max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W) {
  n=N,m=M;
  for(int i=0;i<m;i++){
    pref[X[i]][Y[i]+1]+=W[i];
  }
  for(int i=0;i<=n;i++){
    for(int j=1;j<=n;j++){
      pref[i][j]+=pref[i][j-1];
    }
  }
  n=N,m=M;
  for(int i=0;i<=n;i++){
    dp[0][i]=p(1,0,i);
    //cerr<<dp[0][i]<<" ";
  }//cerr<<"\n\n";
  for(int i=1;i<n;i++){
    lint max1=0;
    for(int j=0;j<=n;j++){
      max1=max(max1,up[i-1][j]-pref[i-1][j]);
      dp[i][j]=max(dp[i][j],max1+pref[i-1][j]+p(i+1,0,j));
      up[i][j]=max(up[i][j],max1+pref[i-1][j]);
      up[i][j]=max(up[i][j],dp[i-1][j]);
    }  
    max1=0;
    for(int j=n;0<=j;j--){
      max1=max(max1,dp[i-1][j]);
      dp[i][j]=max(dp[i][j],max1-p(i,0,j)+p(i+1,0,j));
    }
/*
    for(int j=0;j<=n;j++){
      cerr<<dp[i][j]<<" ";
    }cerr<<"\n";
    for(int j=0;j<=n;j++){
      cerr<<up[i][j]<<" ";
    }cerr<<"\n\n";
*/
  }
  lint ans=0;
  for(int i=0;i<=n;i++){
    ans=max(ans,dp[n-1][i]);
  }
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 526 ms 461944 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Runtime error 490 ms 465780 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 534 ms 458068 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2408 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 7772 KB Output is correct
10 Correct 2 ms 14172 KB Output is correct
11 Correct 1 ms 7772 KB Output is correct
12 Correct 4 ms 14172 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 2 ms 14172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2408 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 7772 KB Output is correct
10 Correct 2 ms 14172 KB Output is correct
11 Correct 1 ms 7772 KB Output is correct
12 Correct 4 ms 14172 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 2 ms 14172 KB Output is correct
15 Correct 3 ms 13916 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
17 Correct 9 ms 15076 KB Output is correct
18 Correct 15 ms 15196 KB Output is correct
19 Correct 9 ms 15196 KB Output is correct
20 Correct 9 ms 15060 KB Output is correct
21 Correct 9 ms 15192 KB Output is correct
22 Correct 16 ms 16144 KB Output is correct
23 Correct 5 ms 14172 KB Output is correct
24 Correct 6 ms 14684 KB Output is correct
25 Correct 3 ms 14172 KB Output is correct
26 Correct 3 ms 14172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2408 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 7772 KB Output is correct
10 Correct 2 ms 14172 KB Output is correct
11 Correct 1 ms 7772 KB Output is correct
12 Correct 4 ms 14172 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 2 ms 14172 KB Output is correct
15 Correct 3 ms 13916 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
17 Correct 9 ms 15076 KB Output is correct
18 Correct 15 ms 15196 KB Output is correct
19 Correct 9 ms 15196 KB Output is correct
20 Correct 9 ms 15060 KB Output is correct
21 Correct 9 ms 15192 KB Output is correct
22 Correct 16 ms 16144 KB Output is correct
23 Correct 5 ms 14172 KB Output is correct
24 Correct 6 ms 14684 KB Output is correct
25 Correct 3 ms 14172 KB Output is correct
26 Correct 3 ms 14172 KB Output is correct
27 Correct 81 ms 220576 KB Output is correct
28 Correct 39 ms 37712 KB Output is correct
29 Correct 123 ms 227496 KB Output is correct
30 Correct 123 ms 227408 KB Output is correct
31 Correct 122 ms 227456 KB Output is correct
32 Correct 48 ms 32336 KB Output is correct
33 Correct 122 ms 227460 KB Output is correct
34 Correct 141 ms 227460 KB Output is correct
35 Correct 93 ms 223096 KB Output is correct
36 Correct 132 ms 227440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 534 ms 458068 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 526 ms 461944 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -