#include "fish.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<int> a;
vector<vector<vector<int>>> memo;
int N,M;
int dp(int x, int last, int lastlast){
if(memo[x][last][lastlast]!=-1) return memo[x][last][lastlast];
if(x==N){
if(last&&!lastlast) return memo[x][last][lastlast]=a[x-2];
if(!last&&lastlast) return memo[x][last][lastlast]=a[x-1];
return memo[x][last][lastlast]=0;
}
int take=dp(x+1, 1, last);
if(last==0&&x>0) take+=a[x-1];
int notake=dp(x+1, 0, last);
if(lastlast==1&&last==0) notake+=a[x-1];
return memo[x][last][lastlast] = max(take, notake);
}
long long max_weights(signed n, signed m, std::vector<signed> X, std::vector<signed> Y, std::vector<signed> W) {
N=n; M=m;
a.resize(N, 0);
memo.resize(N+1, vector<vector<int>>(2, vector<int>(2,-1)));
for (int i = 0; i < M; i++) a[X[i]] = W[i];
int p=dp(0,0,0);
return p;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
24660 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
54 ms |
28144 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '798633080' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
23896 KB |
Output is correct |
2 |
Correct |
22 ms |
23900 KB |
Output is correct |
3 |
Correct |
32 ms |
23648 KB |
Output is correct |
4 |
Correct |
30 ms |
25344 KB |
Output is correct |
5 |
Incorrect |
49 ms |
27712 KB |
1st lines differ - on the 1st token, expected: '1673106170551', found: '1673139594741' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '7', found: '6' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '7', found: '6' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '7', found: '6' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
23896 KB |
Output is correct |
2 |
Correct |
22 ms |
23900 KB |
Output is correct |
3 |
Correct |
32 ms |
23648 KB |
Output is correct |
4 |
Correct |
30 ms |
25344 KB |
Output is correct |
5 |
Incorrect |
49 ms |
27712 KB |
1st lines differ - on the 1st token, expected: '1673106170551', found: '1673139594741' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
24660 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453' |
2 |
Halted |
0 ms |
0 KB |
- |