#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define ull unsigned long long
#define pb push_back
#define inf 1000000000000000000
#define linf 1000000000
#define mpr make_pair
#define in insert
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
//author :: E.Mustafayev
using namespace std;
const int Max= 100000;
vector<vector<vector<ll>>> dp(Max,vector<vector<ll>>(2,vector<ll>(2)));
vector<int>v(Max);
int N;
ll solve(int col, bool a, bool b) {
if (col==N) {
return 0;
}
ll &res=dp[col][a][b];
if (res!=-1) {
return res;
}
res=solve(col+1,b,false);
ll x=0;
if (col>0&& b){
x-=v[col];
}
if (col>0&&!a&&!b){
x+=v[col-1];
}
if (col+1<N){
x+=v[col+1];
}
res=max(res,x+solve(col+1,b,true));
return res;
}
ll max_weights(int n, int m, vector<int>x, vector<int>y, vector<int>w) {
for(int i=0;i<m;i++){
v[x[i]]=w[i];
}
for(int i=0;i<Max;i++){
for(int j=0;j<2;j++){
for(int k=0;k<2;k++){
dp[i][j][k]=-1;
}
}
}
bool a=true,b=true;
N=n;
ll ans=0;
for(int i=0;i<m;i++){
if(x[i]%2){
a=false;
}
ans+=w[i];
}
if(a){
return ans;
}
ans=0;
for(int i=0;i<2;i++){
ll ans1=0;
for(int j=0;j<m;j++){
if(x[j]>1){
b=false;
}
ans1+=w[j];
}
ans=max(ans,ans1);
}
if(b){
return ans;
}
ll res=solve(0,false,false);
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
17356 KB |
Output is correct |
2 |
Correct |
46 ms |
17904 KB |
Output is correct |
3 |
Correct |
17 ms |
15572 KB |
Output is correct |
4 |
Correct |
18 ms |
15496 KB |
Output is correct |
5 |
Correct |
102 ms |
22532 KB |
Output is correct |
6 |
Correct |
99 ms |
22532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
15520 KB |
Output is correct |
2 |
Incorrect |
78 ms |
19356 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '80901044391025' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
15560 KB |
Output is correct |
2 |
Correct |
28 ms |
23380 KB |
Output is correct |
3 |
Correct |
39 ms |
23840 KB |
Output is correct |
4 |
Correct |
41 ms |
24148 KB |
Output is correct |
5 |
Correct |
62 ms |
25708 KB |
Output is correct |
6 |
Correct |
48 ms |
25736 KB |
Output is correct |
7 |
Correct |
53 ms |
25700 KB |
Output is correct |
8 |
Correct |
50 ms |
25692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
15512 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
15512 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
15512 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
15560 KB |
Output is correct |
2 |
Correct |
28 ms |
23380 KB |
Output is correct |
3 |
Correct |
39 ms |
23840 KB |
Output is correct |
4 |
Correct |
41 ms |
24148 KB |
Output is correct |
5 |
Correct |
62 ms |
25708 KB |
Output is correct |
6 |
Correct |
48 ms |
25736 KB |
Output is correct |
7 |
Correct |
53 ms |
25700 KB |
Output is correct |
8 |
Correct |
50 ms |
25692 KB |
Output is correct |
9 |
Incorrect |
54 ms |
25696 KB |
1st lines differ - on the 1st token, expected: '99999', found: '66666' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
17356 KB |
Output is correct |
2 |
Correct |
46 ms |
17904 KB |
Output is correct |
3 |
Correct |
17 ms |
15572 KB |
Output is correct |
4 |
Correct |
18 ms |
15496 KB |
Output is correct |
5 |
Correct |
102 ms |
22532 KB |
Output is correct |
6 |
Correct |
99 ms |
22532 KB |
Output is correct |
7 |
Correct |
19 ms |
15520 KB |
Output is correct |
8 |
Incorrect |
78 ms |
19356 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '80901044391025' |
9 |
Halted |
0 ms |
0 KB |
- |