using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ int[][][] dp = new int[N][][]; for(int i=0;i C) continue; dp[i][j][W[i] + W[j]] = L[i] + L[j]; } } //for(int i=0;i L[k] && L[i] != L[k]){ if(c + W[k] <= C){ dp[j][k][c + W[k]] = Math.Max(dp[j][k][c + W[k]], dp[i][j][c] + L[k]); } } if(L[i] > L[j] && L[j] < L[k] && L[i] != L[k]){ if(c + W[k] <= C){ dp[j][k][c + W[k]] = Math.Max(dp[j][k][c + W[k]], dp[i][j][c] + L[k]); } } } } } } int max = 0; for(int i=0;iint.Parse(e));} static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));} static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));} }