#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";
}*/
DP[0][0] = 0;
for(int i = 1; i <= n + 1; i++){
if(i != 1){
for(int j = n; j >= 1; j--){
if(j == n){
dp[i][j] = min(DP[i - 2][j], dp[i - 2][1]) + val[i][j];
}
else dp[i][j] = max(dp[i - 1][j + 1], dp[i][j + 1]) + val[i][j];
// dp[i][j] = max(dp[i][j], dp[i - 1][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];
// DP[i][j] = max(DP[i - 1][j], DP[i][j]);
}
}
for(int i = 1; i <= n + 1; i++) dp[n + 1][1] = max(dp[i][1], dp[n + 1][1]);
return dp[n + 1][1];
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1091 ms |
77980 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1095 ms |
69576 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
1st lines differ - on the 1st token, expected: '3', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
1st lines differ - on the 1st token, expected: '3', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
1st lines differ - on the 1st token, expected: '3', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1095 ms |
69576 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1091 ms |
77980 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |