#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] = max(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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
66872 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Execution timed out |
1091 ms |
71456 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1095 ms |
65336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
2516 KB |
Output is correct |
10 |
Correct |
5 ms |
5332 KB |
Output is correct |
11 |
Correct |
2 ms |
2516 KB |
Output is correct |
12 |
Correct |
4 ms |
5332 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
4 ms |
5296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
2516 KB |
Output is correct |
10 |
Correct |
5 ms |
5332 KB |
Output is correct |
11 |
Correct |
2 ms |
2516 KB |
Output is correct |
12 |
Correct |
4 ms |
5332 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
4 ms |
5296 KB |
Output is correct |
15 |
Correct |
3 ms |
5332 KB |
Output is correct |
16 |
Correct |
2 ms |
1236 KB |
Output is correct |
17 |
Correct |
15 ms |
6368 KB |
Output is correct |
18 |
Correct |
14 ms |
6240 KB |
Output is correct |
19 |
Correct |
14 ms |
6752 KB |
Output is correct |
20 |
Correct |
15 ms |
6788 KB |
Output is correct |
21 |
Correct |
19 ms |
6720 KB |
Output is correct |
22 |
Correct |
25 ms |
8172 KB |
Output is correct |
23 |
Correct |
6 ms |
6240 KB |
Output is correct |
24 |
Correct |
12 ms |
6752 KB |
Output is correct |
25 |
Correct |
3 ms |
5332 KB |
Output is correct |
26 |
Correct |
6 ms |
5844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
2516 KB |
Output is correct |
10 |
Correct |
5 ms |
5332 KB |
Output is correct |
11 |
Correct |
2 ms |
2516 KB |
Output is correct |
12 |
Correct |
4 ms |
5332 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
4 ms |
5296 KB |
Output is correct |
15 |
Correct |
3 ms |
5332 KB |
Output is correct |
16 |
Correct |
2 ms |
1236 KB |
Output is correct |
17 |
Correct |
15 ms |
6368 KB |
Output is correct |
18 |
Correct |
14 ms |
6240 KB |
Output is correct |
19 |
Correct |
14 ms |
6752 KB |
Output is correct |
20 |
Correct |
15 ms |
6788 KB |
Output is correct |
21 |
Correct |
19 ms |
6720 KB |
Output is correct |
22 |
Correct |
25 ms |
8172 KB |
Output is correct |
23 |
Correct |
6 ms |
6240 KB |
Output is correct |
24 |
Correct |
12 ms |
6752 KB |
Output is correct |
25 |
Correct |
3 ms |
5332 KB |
Output is correct |
26 |
Correct |
6 ms |
5844 KB |
Output is correct |
27 |
Correct |
149 ms |
153652 KB |
Output is correct |
28 |
Correct |
67 ms |
23696 KB |
Output is correct |
29 |
Correct |
216 ms |
151668 KB |
Output is correct |
30 |
Correct |
248 ms |
194560 KB |
Output is correct |
31 |
Correct |
232 ms |
195076 KB |
Output is correct |
32 |
Correct |
85 ms |
20916 KB |
Output is correct |
33 |
Correct |
234 ms |
218992 KB |
Output is correct |
34 |
Correct |
235 ms |
218992 KB |
Output is correct |
35 |
Correct |
169 ms |
159220 KB |
Output is correct |
36 |
Correct |
217 ms |
164848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1095 ms |
65336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
66872 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |