답안 #1056892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1056892 2024-08-13T12:11:33 Z noyancanturk 메기 농장 (IOI22_fish) C++17
35 / 100
1000 ms 467260 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++){
    for(int j=0;j<=n;j++){
      for(int k=j;k<=n;k++){
        dp[i][j]=max(dp[i][j],dp[i-1][k]-p(i,0,j)+p(i+1,0,j));
        up[i][k]=max(up[i][k],dp[i-1][k]-p(i,0,j));
      }
      for(int k=0;k<=j;k++){
        dp[i][j]=max(dp[i][j],up[i-1][k]+p(i-1,k+1,j)+p(i+1,0,j));
        up[i][j]=max(up[i][j],up[i-1][k]+p(i-1,k+1,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 527 ms 461876 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Runtime error 509 ms 467260 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 468 ms 457992 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 6 ms 7772 KB Output is correct
10 Correct 26 ms 14012 KB Output is correct
11 Correct 7 ms 7772 KB Output is correct
12 Correct 27 ms 14008 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 29 ms 14048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 6 ms 7772 KB Output is correct
10 Correct 26 ms 14012 KB Output is correct
11 Correct 7 ms 7772 KB Output is correct
12 Correct 27 ms 14008 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 29 ms 14048 KB Output is correct
15 Correct 28 ms 14032 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 35 ms 15720 KB Output is correct
18 Correct 37 ms 15700 KB Output is correct
19 Correct 35 ms 15464 KB Output is correct
20 Correct 40 ms 15568 KB Output is correct
21 Correct 32 ms 15708 KB Output is correct
22 Correct 44 ms 17248 KB Output is correct
23 Correct 30 ms 14416 KB Output is correct
24 Correct 30 ms 15188 KB Output is correct
25 Correct 30 ms 14164 KB Output is correct
26 Correct 29 ms 14420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 6 ms 7772 KB Output is correct
10 Correct 26 ms 14012 KB Output is correct
11 Correct 7 ms 7772 KB Output is correct
12 Correct 27 ms 14008 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 29 ms 14048 KB Output is correct
15 Correct 28 ms 14032 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 35 ms 15720 KB Output is correct
18 Correct 37 ms 15700 KB Output is correct
19 Correct 35 ms 15464 KB Output is correct
20 Correct 40 ms 15568 KB Output is correct
21 Correct 32 ms 15708 KB Output is correct
22 Correct 44 ms 17248 KB Output is correct
23 Correct 30 ms 14416 KB Output is correct
24 Correct 30 ms 15188 KB Output is correct
25 Correct 30 ms 14164 KB Output is correct
26 Correct 29 ms 14420 KB Output is correct
27 Execution timed out 1059 ms 81676 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 468 ms 457992 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 527 ms 461876 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -