제출 #1036763

#제출 시각아이디문제언어결과실행 시간메모리
1036763XJP12메기 농장 (IOI22_fish)C++17
0 / 100
17 ms6744 KiB
#include <bits/stdc++.h> #include "fish.h" using namespace std; typedef long long ll; typedef vector<int> vi; ll max_weights(int n, int m, vi x, vi y, vi w){ ll dp[n][4]; vi v(n,0); ll cont=0; for(int i=0; i<n; i++){ if(cont==m) break; if(x[cont]==i){ v[i]=w[cont]; cont++; } } if(n==2){ return max(w[0], w[1]); } for(int i=2; i<n; i++){ if(i==2){ dp[i][0]=0; dp[i][1]=v[i]+v[i-2]; dp[i][2]=v[i-1]; dp[i][3]=v[i]; continue; } dp[i][0]=max(dp[i-1][0], dp[i-1][2]); dp[i][1]=max(dp[i-1][0]+v[i-1] + v[i], dp[i-1][2] + v[i]); dp[i][2]=max(dp[i-1][1], dp[i-1][3]); dp[i][3]=max(dp[i-1][1]+ v[i], dp[i-1][3] + v[i]); } return max(max(dp[n-1][0], dp[n-1][1]),max(dp[n-1][2],dp[n-1][3])); }
#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...