結果
| 問題 |
No.115 遠足のおやつ
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2014-12-29 02:22:32 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 5,000 ms |
| コード長 | 1,792 bytes |
| コンパイル時間 | 1,086 ms |
| コンパイル使用メモリ | 115,584 KB |
| 実行使用メモリ | 19,584 KB |
| 最終ジャッジ日時 | 2025-01-03 01:01:33 |
| 合計ジャッジ時間 | 3,481 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
コンパイルメッセージ
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;
class TEST{
static void Main(){
Sol mySol =new Sol();
mySol.Solve();
}
}
class Sol{
public void Solve(){
dp=new int[D+1][];
int[][][] route=new int[D+1][][];
for(int i=0;i<D+1;i++){
dp[i]=new int[K+1];
route[i]=new int[K+1][];
for(int j=0;j<K+1;j++){
route[i][j]=new int[K];
for(int k=0;k<K;k++)route[i][j][k]=N+1;
}
}
dp[0][0]=1;
for(int i=1;i<=N;i++){
for(int k=K-1;k>=0;k--){
for(int d=D;d>=0;d--){
if(dp[d][k]==0)continue;
if(d+i<=D){
dp[d+i][k+1]=1;
bool chk=true;
route[d][k][k]=i;
for(int rr=0;rr<k+1;rr++){
if(route[d+i][k+1][rr]>route[d][k][rr]){
chk=false;break;
}
}
if(!chk){
for(int rr=0;rr<k+1;rr++){
route[d+i][k+1][rr]=route[d][k][rr];
}
}
route[d][k][k]=N+1;
}
}
}
}
if(dp[D][K]==0){
Console.WriteLine(-1);
return;
}
for(int i=0;i<K;i++){
Console.Write(i==0?"{0}":" {0}",route[D][K][i]);
}
Console.WriteLine();
}
int[][] dp;
int N,D,K;
public Sol(){
var d=ria();
N=d[0];D=d[1];K=d[2];
}
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(){return Console.ReadLine().Split(' ');}
static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
kuuso1