結果

問題 No.844 split game
ユーザー kuuso1kuuso1
提出日時 2019-06-28 22:28:21
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 1,969 bytes
コンパイル時間 2,855 ms
コンパイル使用メモリ 111,216 KB
実行使用メモリ 36,936 KB
最終ジャッジ日時 2023-09-14 22:17:27
合計ジャッジ時間 12,460 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
29,916 KB
testcase_01 AC 125 ms
35,012 KB
testcase_02 AC 178 ms
29,836 KB
testcase_03 AC 162 ms
34,736 KB
testcase_04 AC 104 ms
25,620 KB
testcase_05 AC 197 ms
33,044 KB
testcase_06 AC 103 ms
28,684 KB
testcase_07 AC 105 ms
32,396 KB
testcase_08 AC 83 ms
25,852 KB
testcase_09 AC 153 ms
24,056 KB
testcase_10 AC 196 ms
30,016 KB
testcase_11 AC 202 ms
31,384 KB
testcase_12 AC 152 ms
28,268 KB
testcase_13 AC 118 ms
27,580 KB
testcase_14 AC 127 ms
30,752 KB
testcase_15 AC 223 ms
36,904 KB
testcase_16 AC 218 ms
36,920 KB
testcase_17 AC 220 ms
34,952 KB
testcase_18 AC 221 ms
36,936 KB
testcase_19 AC 223 ms
34,892 KB
testcase_20 AC 217 ms
34,892 KB
testcase_21 AC 218 ms
34,984 KB
testcase_22 AC 218 ms
36,924 KB
testcase_23 AC 67 ms
20,788 KB
testcase_24 AC 73 ms
22,728 KB
testcase_25 AC 68 ms
20,720 KB
testcase_26 AC 64 ms
20,652 KB
testcase_27 AC 71 ms
24,744 KB
testcase_28 AC 63 ms
22,708 KB
testcase_29 AC 70 ms
22,760 KB
testcase_30 AC 72 ms
22,656 KB
testcase_31 AC 71 ms
22,800 KB
testcase_32 AC 63 ms
20,712 KB
testcase_33 AC 74 ms
22,856 KB
testcase_34 AC 69 ms
20,700 KB
testcase_35 AC 77 ms
22,792 KB
testcase_36 AC 71 ms
22,704 KB
testcase_37 AC 85 ms
24,732 KB
testcase_38 AC 106 ms
25,244 KB
testcase_39 AC 153 ms
24,396 KB
testcase_40 AC 93 ms
30,104 KB
testcase_41 AC 59 ms
20,700 KB
testcase_42 AC 59 ms
20,712 KB
testcase_43 AC 60 ms
18,672 KB
testcase_44 AC 60 ms
20,664 KB
testcase_45 AC 60 ms
20,696 KB
testcase_46 AC 59 ms
20,788 KB
testcase_47 AC 60 ms
20,728 KB
testcase_48 AC 60 ms
22,764 KB
testcase_49 AC 60 ms
22,740 KB
testcase_50 AC 60 ms
20,712 KB
testcase_51 AC 60 ms
20,620 KB
testcase_52 AC 62 ms
22,692 KB
testcase_53 AC 59 ms
20,600 KB
testcase_54 AC 59 ms
18,652 KB
testcase_55 AC 60 ms
20,736 KB
testcase_56 AC 62 ms
22,768 KB
testcase_57 AC 61 ms
22,752 KB
testcase_58 AC 61 ms
20,712 KB
testcase_59 AC 61 ms
22,784 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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(){
		
		long Inf = (long) 1e18;
		long[][] dp = new long[2][];
		for(int i=0;i<2;i++) {
			dp[i] = new long[N + 1];
			for(int j=0;j<=N;j++) dp[i][j] = -Inf;
		}
		List<int>[] E = new List<int>[N + 1];
		for(int i=0;i<N+1;i++) E[i] = new List<int>();
		for(int i=0;i<M;i++){
			E[L[i]].Add(i);
		}
		
		dp[1][0] = 0;
		for(int i=0;i<N;i++){
			for(int j=0;j<2;j++){
				if(dp[j][i] == -Inf) continue;
				foreach(var e in E[i]){
					long lose = A;
					if(R[e] + 1 == N) lose -= A;
					if(j == 0) lose += A;
					dp[1][R[e] + 1] = Math.Max(dp[1][R[e] + 1], dp[j][i] + P[e] - lose);
				}
				dp[0][i + 1] = Math.Max(dp[0][i + 1], dp[j][i]);
				dp[1][i + 1] = Math.Max(dp[1][i + 1], dp[j][i] - (i + 1 == N ? 0 : A));
			}
//for(int k=0;k<2;k++) Console.WriteLine("{0};{1}",k,String.Join(" ",dp[k]));
		}
		
		Console.WriteLine(Math.Max(dp[0][N], dp[1][N]));
		
	}
	int N,M;
	long A;
	int[] L,R;
	long[] P;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1]; A = d[2];
		L = new int[M];
		R = new int[M];
		P = new long[M];
		for(int i=0;i<M;i++){
			d = ria();
			L[i] = d[0] - 1; R[i] = d[1] - 1; P[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));}
}
0