Submission #1247487

#TimeUsernameProblemLanguageResultExecution timeMemory
1247487emad234Catfish Farm (IOI22_fish)C++20
0 / 100
129 ms4976 KiB
#include "fish.h"
#include "bits/stdc++.h"
#define F first
#define S second
#define ll long long
#define pii pair<ll,ll>
using namespace std;
const ll  mxN = 1e6 + 33;
const ll  mod = 998244353;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T>
using indexed_set = tree<T,null_type,less<T>,rb_tree_tag, tree_order_statistics_node_update>;
ll dp[400][400];
ll prfx[400][400];
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
  for(int i = 0;i < M;i++){
    prfx[X[i]][Y[i]] = W[i];
  }
  for(int i = 0;i < N;i++){
    for(int j = 1;j < N;j++){
      prfx[i][j] += prfx[i][j - 1];
    }
  }
  ll ans = 0;
  for(int i = 1;i < N;i++){
    for(int j = 0;j < N;j++){
      for(int k = 0;k < N;k++){
        ll x = 0;
        if(j) x = prfx[i - 1][j - 1];
        if(k > 0) x -= prfx[i - 1][k - 1];
        if(k > j) x = 0;
        dp[i][j] = max(dp[i][j],dp[i - 1][k] + x);
      }
      ans = max(ans,dp[i][j]);
      cout<<dp[i][j]<<' ';
    }
    cout<<'\n';
  }
  return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...