Submission #1056573

# Submission time Handle Problem Language Result Execution time Memory
1056573 2024-08-13T10:08:18 Z noyancanturk Catfish Farm (IOI22_fish) C++17
0 / 100
558 ms 465696 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);
  }
  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));
      }
    }  
  }
  lint ans=0;
  for(int i=0;i<=n;i++){
    ans=max(ans,dp[n-1][i]);
  }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 558 ms 461908 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Runtime error 547 ms 465696 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 550 ms 458068 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Incorrect 1 ms 2392 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Incorrect 1 ms 2392 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Incorrect 1 ms 2392 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 550 ms 458068 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 558 ms 461908 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -