#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 pb push_back
#define MID ((l+r)/2)
#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;
typedef vector <ll> vi;
typedef vector <long long > vl;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;
void printVct(vl &v, string s = ""){
cout<<s<<": ";
for (ll i=0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
#define MAXN 100000
ll n,m;
vl arr;
vl dp;
void tabb(ll n) {
for (ll i=0; i<n; i++) cout<<"\t";
}
long long solve(ll c = 0, ll tab = 0){
// tabb(tab);
// dbg(c);
if (c >= n) return 0;
if (dp[c] == -1){
dp[c] = 0;
if (c < n-1){
dp[c] = arr[c+1];
dp[c] = max(dp[c], solve(c+1, tab+1));
if (c < n-2){
// long long a = solve(c+2, tab+1) + arr[c+1];
// tabb(tab);
// dbg2(a, arr[c+1]);
dp[c] = max(dp[c], solve(c+2, tab+1) + arr[c+1]);
if (c < n-3){
dp[c] = max(dp[c], solve(c+3, tab+1) + arr[c+1] + arr[c+2]);
}
}
}
}
// tabb(tab);
// dbg(dp[c]);
return dp[c];
}
long long max_weights(int N, int M, vi X, vi Y, vi W) {
n= N, m =M;
long long ans = 0;
arr.assign(n, 0);
for (ll i =0 ; i<m; i++){
arr[X[i]] = W[i];
}
// printVct(arr, "arr");
dp.assign(n, -1);
long long a = solve(0);
dp.assign(n, -1);
long long b = solve(1) + arr[0];
// dbg2(a,b);
ans = max(a,b);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
21 ms |
6356 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
4948 KB |
Output is correct |
2 |
Correct |
4 ms |
4948 KB |
Output is correct |
3 |
Correct |
19 ms |
5720 KB |
Output is correct |
4 |
Correct |
14 ms |
6468 KB |
Output is correct |
5 |
Correct |
29 ms |
8868 KB |
Output is correct |
6 |
Correct |
24 ms |
8248 KB |
Output is correct |
7 |
Correct |
28 ms |
8896 KB |
Output is correct |
8 |
Correct |
28 ms |
8884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
4948 KB |
Output is correct |
2 |
Correct |
4 ms |
4948 KB |
Output is correct |
3 |
Correct |
19 ms |
5720 KB |
Output is correct |
4 |
Correct |
14 ms |
6468 KB |
Output is correct |
5 |
Correct |
29 ms |
8868 KB |
Output is correct |
6 |
Correct |
24 ms |
8248 KB |
Output is correct |
7 |
Correct |
28 ms |
8896 KB |
Output is correct |
8 |
Correct |
28 ms |
8884 KB |
Output is correct |
9 |
Incorrect |
31 ms |
8632 KB |
1st lines differ - on the 1st token, expected: '99999', found: '66666' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
21 ms |
6356 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453' |
2 |
Halted |
0 ms |
0 KB |
- |