#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define sz(x) (ll)x.size()
#define F first
#define S second
#define endl "\n"
#define pb push_back
typedef vector <ll> vi;
typedef vector <long long> vl;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
void printVct(vl &v){
for(ll i =0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
long long getSum(ll l, ll r, const vl &s){
if (l == 0) return s[r];
return s[r] - s[l-1];
}
#define N 100001
vl arr;
ll n, m;
long long dp[N+1];
long long solve(ll i){ //wall already present at position c
if (i >= n) return 0;
if (i == n-2) return arr.back();
if (dp[i] != -1) return dp[i];
long long ans =0;
//i+1
if (i < n-1){
ans = max(ans, solve(i+1));
}
//i+2
if (i < n-2){
ans = max(ans, solve(i+2) + arr[i+1]);
}
//i+3
if (i < n-3){
ans = max(ans, solve(i+3) + arr[i+1] + arr[i+2]);
}
dp[i] = ans;
return dp[i];
}
void init_dp(){
for (ll i =0; i<=n; i++){
dp[i] = -1;
}
}
long long max_weights(int NN, int M, vi X, vi Y, vi w){
n = NN, m = M;
//create arr
arr.assign(n, 0);
for (ll i =0; i<m; i++){
ll x = X[i];
arr[x] = w[i];
}
// cout<<"arr: ";
// printVct(arr);
long long ans = 0;
init_dp();
ans = solve(0);
for (ll i = 1; i<=min(2, n-1); i++){
init_dp();
ans = max(ans, solve(i) + arr[i-1]);
}
return ans;
}
/*
7 7
0 0 2
1 0 1
2 0 0
3 0 5
4 0 3
5 0 3
6 0 4
6 4
0 2 5
2 1 4
4 4 1
6 3 3
6 6
0 2 5
1 1 4
0 4 1
0 3 3
1 2 4
1 6 2
2 3
0 1 2
0 0 4
1 1 3
5 4
0 2 5
1 1 2
4 4 1
3 3 3
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
8024 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
6712 KB |
Output is correct |
2 |
Correct |
6 ms |
6492 KB |
Output is correct |
3 |
Correct |
18 ms |
7260 KB |
Output is correct |
4 |
Correct |
15 ms |
8028 KB |
Output is correct |
5 |
Correct |
29 ms |
10592 KB |
Output is correct |
6 |
Correct |
25 ms |
9812 KB |
Output is correct |
7 |
Correct |
29 ms |
10556 KB |
Output is correct |
8 |
Correct |
28 ms |
10588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
6712 KB |
Output is correct |
2 |
Correct |
6 ms |
6492 KB |
Output is correct |
3 |
Correct |
18 ms |
7260 KB |
Output is correct |
4 |
Correct |
15 ms |
8028 KB |
Output is correct |
5 |
Correct |
29 ms |
10592 KB |
Output is correct |
6 |
Correct |
25 ms |
9812 KB |
Output is correct |
7 |
Correct |
29 ms |
10556 KB |
Output is correct |
8 |
Correct |
28 ms |
10588 KB |
Output is correct |
9 |
Incorrect |
27 ms |
10328 KB |
1st lines differ - on the 1st token, expected: '99999', found: '66666' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
8024 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453' |
2 |
Halted |
0 ms |
0 KB |
- |