#include<bits/stdc++.h>
//#include "prison.h"
#pragma GCC optimize ("O3")
using namespace std;
#define el "\n"
#define se " "
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
const ll INF=1e18,ch=1e18;
ll a,b,c,d,n,COST,t,last,ab,ba,n1,n2,fl1,fl2,o1,o2,flag,flag1,flag2,g,m,m1,m2,i,j,lr,f,k,l,r,y,o,p,mx=-ch,mx1=-ch,mx2=-ch,q,q1,q2,q3,q4,mn=ch,mn1=ch,mn2=ch,f1,f2,f3,pos,ans,sum,sz=1,MOD=1e9+7,zero=0,a1,b1,c1,val,sum1,cur,res,ans1,res1,kk,kkk,cnt,cnt1,fl;
pair < ll , pair < ll , ll > > A[300005];
pair < ll, ll > B[300005];
ll C[300005];
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W)
{
n=N;k=M;
for(i=1;i<=k;i++)
{
A[i].ff=X[i-1]+1;
A[i].ss.ff=Y[i-1]+1;
A[i].ss.ss=W[i-1];
if (A[i].ff%2!=0) q1++;
if (A[i].ff<=2) q2++;
}
// if (q2==k)
// {
// for(i=1;i<=k;i++)
// {
// j=A[i].ss.ff;
// if (B[j].ff==0)
// {
// B[j].ff=A[i].ss.ss;
// f+=B[j].ff;
// }
// else
// {
// B[j].ss=A[i].ss.ss;
// f-=B[j].ff;
// f+=max(B[j].ff,B[j].ss);
// }
// }
// return f;
// }
// else
if (q1==k)
{
for(i=1;i<=k;i++)
{
f+=A[i].ss.ss;
}
return f;
}
else
{
ll dp[300005][3]={0};
for(i=1;i<=k;i++)
{
C[A[i].ff]=A[i].ss.ss;
}
dp[1][0]=0;
dp[1][1]=C[1];
for(i=2;i<=300001;i++)
{
dp[i][0]=max(dp[i-1][0],dp[i-1][1]);
dp[i][1]=max(dp[i-1][1],dp[i-1][0]+C[i]);
}
return max(dp[300001][0],dp[300001][1]);
}
}
//int main()
//{
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
// cin>>n>>a>>b;
// vector < vector < int > > v=devise_strategy(a,b);
//}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
11092 KB |
Output is correct |
2 |
Correct |
40 ms |
12024 KB |
Output is correct |
3 |
Correct |
3 ms |
7252 KB |
Output is correct |
4 |
Correct |
3 ms |
7252 KB |
Output is correct |
5 |
Correct |
87 ms |
21368 KB |
Output is correct |
6 |
Correct |
88 ms |
21428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
7252 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7252 KB |
Output is correct |
2 |
Correct |
4 ms |
7252 KB |
Output is correct |
3 |
Incorrect |
19 ms |
10560 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
7316 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
7316 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
7316 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7252 KB |
Output is correct |
2 |
Correct |
4 ms |
7252 KB |
Output is correct |
3 |
Incorrect |
19 ms |
10560 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
11092 KB |
Output is correct |
2 |
Correct |
40 ms |
12024 KB |
Output is correct |
3 |
Correct |
3 ms |
7252 KB |
Output is correct |
4 |
Correct |
3 ms |
7252 KB |
Output is correct |
5 |
Correct |
87 ms |
21368 KB |
Output is correct |
6 |
Correct |
88 ms |
21428 KB |
Output is correct |
7 |
Incorrect |
4 ms |
7252 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
8 |
Halted |
0 ms |
0 KB |
- |