結果
| 問題 |
No.496 ワープクリスタル (給料日前編)
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2017-03-24 22:57:28 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 1,952 bytes |
| コンパイル時間 | 874 ms |
| コンパイル使用メモリ | 115,240 KB |
| 実行使用メモリ | 26,072 KB |
| 最終ジャッジ日時 | 2024-07-05 22:51:51 |
| 合計ジャッジ時間 | 2,439 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
コンパイルメッセージ
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 H = Gy+1;
int W = Gx+1;
int[][] dp = new int[H][];
int Inf = (int)1e9;
for(int i=0;i<H;i++){
dp[i] = new int[W];
for(int j=0;j<W;j++){
dp[i][j] = Inf;
}
}
dp[0][0] = 0;
for(int k=0;k<N;k++){
for(int i=H-1;i>=0;i--){
for(int j=W-1;j>=0;j--){
if(dp[i][j] == Inf) continue;
int ny = i + Y[k];
int nx = j + X[k];
int nc = dp[i][j] + C[k];
if(InRange(ny,0,H) && InRange(nx,0,W)){
dp[ny][nx] = Math.Min(dp[ny][nx],nc);
}
}
}
//for(int i=0;i<H;i++)Console.WriteLine(String.Join(" ",dp[i]));Console.WriteLine();
}
int min = Inf;
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
int rest = Gx - j + Gy - i;
min = Math.Min(rest*F + dp[i][j], min);
}
}
Console.WriteLine(min);
}
bool InRange(int t, int l, int r){
return l <= t && t < r;
}
int Gx,Gy,N,F;
int[] X,Y,C;
public Sol(){
var d = ria();
Gx = d[0]; Gy = d[1]; N = d[2]; F = d[3];
X = new int[N];
Y = new int[N];
C = new int[N];
for(int i=0;i<N;i++){
d = ria();
X[i] = d[0]; Y[i] = d[1]; C[i] = 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(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