제출 #626035

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
6260352022-08-11 06:52:13sword060메기 농장 (IOI22_fish)C++17
9 / 100
136 ms11488 KiB
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
long long dp[100005][2],ar[100005];
long long rec(int i,bool f,int m){
if(i>=m)return 0;
if(~dp[i][f])return dp[i][f];
long long z=rec(i+1,1,m);
if(f)return dp[i][0]=max(z,rec(i+1,0,m)+ar[i]);
if(i<m-1)return dp[i][1]=max(z,rec(i+2,0,m)+ar[i]);
return dp[i][1]=0;
}
long long max_weights(int x,int k,vector<int> a,vector<int> b,vector<int> c){
vector<pair<int,int>>l[2];
long long ans=0,cur=0,cur2=0;
bool f=1;
for(int i=0;i<k;i++){
l[a[i]%2].push_back({b[i],c[i]});
if(a[i]%2)cur+=c[i];
else cur2+=c[i];
f&=(b[i]==0);
}
if(f){
for(int i=0;i<x;i++)dp[i][0]=-1,dp[i][1]=-1,ar[i]=0;
for(int i=0;i<k;i++)ar[a[i]]=c[i];
return rec(0,0,x);
}
sort(l[0].begin(),l[0].end());
sort(l[1].begin(),l[1].end());
ans=cur;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...