이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "fish.h"
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#include <vector>
using namespace std;
const int NMAX = 3005;
ll dp[NMAX][NMAX];//klebadi
ll DP[NMAX][NMAX];//zrdadi
ll val[NMAX][NMAX];
const ll linf = 1e18;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,std::vector<int> W) {
int n = N;
int m = M;
for(int i = 0; i < m; i++){
val[X[i] + 1][Y[i] + 1] = W[i];
}
/*for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++) cout << val[i][j] << ' ';
cout << "\n";
}*/
for(int i = 0; i <= n; i++) {
dp[0][i] = -linf;
}
dp[1][n] = -linf;
DP[0][0] = 0;
for(int i = 1; i <= n + 1; i++){
for(int j = n; j >= 1; j--){
if(j == n){
if(i > 1) dp[i][j] = DP[i - 2][j] + val[i][j];
}
else dp[i][j] = max(dp[i - 1][j + 1], dp[i][j + 1]) + val[i][j];
}
for(int j = 1; j <= n; j++){
if(j == 1)DP[i][j] = dp[i - 1][j] + val[i][j];
else DP[i][j] = max(DP[i - 1][j - 1], DP[i][j - 1]) + val[i][j];
}
}
return dp[n + 1][1];
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |