結果
| 問題 |
No.783 門松計画
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2019-01-11 22:47:58 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 109 ms / 2,000 ms |
| コード長 | 2,334 bytes |
| コンパイル時間 | 4,129 ms |
| コンパイル使用メモリ | 113,296 KB |
| 実行使用メモリ | 26,300 KB |
| 最終ジャッジ日時 | 2024-07-23 12:17:50 |
| 合計ジャッジ時間 | 2,645 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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<N;i++){
dp[i] = new int[N][];
for(int j=0;j<N;j++){
dp[i][j] = new int[C + 1];
for(int k=0;k<=C;k++){
dp[i][j][k] = -1;
}
}
}
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
if(L[i] == L[j]) continue;
if(W[i] + W[j] > C) continue;
dp[i][j][W[i] + W[j]] = L[i] + L[j];
}
}
//for(int i=0;i<N;i++) for(int j=0;j<N;j++) for(int c=0;c<=C;c++) if(dp[i][j][c] != -1) Console.WriteLine("{0} {1} {2} {3}",i,j,c,dp[i][j][c]);
for(int c=0;c<C;c++){
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
if(dp[i][j][c] == -1) continue;
for(int k=0;k<N;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]);
}
}
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;i<N;i++){
for(int j=0;j<N;j++){
for(int c=0;c<=C;c++){
if(dp[i][j][c] == -1) continue;
if(L[i] + L[j] == dp[i][j][c]) continue;
//Console.WriteLine("{0} {1} {2} {3}",i,j,c,dp[i][j][c]);
max = Math.Max(max, dp[i][j][c]);
}
}
}
Console.WriteLine(max);
}
int N,C;
int[] L;
int[] W;
public Sol(){
var d = ria();
N = d[0]; C = d[1];
L = ria();
W = ria();
}
static String rs(){return Console.ReadLine();}
static int ri(){return int.Parse(Console.ReadLine());}
static long rl(){return long.Parse(Console.ReadLine());}
static double rd(){return double.Parse(Console.ReadLine());}
static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.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));}
}
kuuso1