Submission #214329


Source Code Expand

Copy
import java.io.BufferedInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
	//public static final int C = 1000000007;
	//static int map[][];
	//static int N;
	//static int M;
	static int tic[][];
	static int dp[][];
	static int a[][];
	

	public static void main(String[] args) {
		//StringBuilder sb = new StringBuilder();
		BufferedInputStream bs = new BufferedInputStream(System.in);
		Scanner sc = new Scanner(bs);

		int n = sc.nextInt();
		
		int h = sc.nextInt();

		
		a = new int[3][2];
		a[0][0] = sc.nextInt();
		a[0][1] = sc.nextInt();
		a[1][0] = sc.nextInt();
		a[1][1] = sc.nextInt();
		a[2][0] = 0;
		a[2][1] = -sc.nextInt();
		
		 dp = new int[n+1][-a[2][1]+1];
		 for (int i=0; i < n+1; i++) {
			 for (int t=0; t < -a[2][1]+1; t++) {
				 dp[i][t] = -1;
			 }
		 }
		//HashMap<Integer, ArrayList<Integer>> hm = new HashMap<Integer, ArrayList<Integer>>();
		
		
		//int map[][] = new int[n][n];
		
		long ans = set(n, h);
		
		
		
		System.out.println(ans);
		
	}
	static long set(int n, long h) {
		if (n == 0) return 0;
		if (h >= -a[2][1] +1) return set(n-1, h + a[2][1]);
		if (dp[n][(int) h] != -1) return dp[n][(int) h];
		
		long m[] = new long[3];
		for (int i=0; i < 3; i++) {
			if (h + a[i][1] <= 0) {
				m[i] = Long.MAX_VALUE;
				continue;
			}
			m[i] = a[i][0] + set(n-1, h + a[i][1]);
		}
		
		return dp[n][(int) h] = (int) Math.min(m[0], Math.min(m[1], m[2]));
	}
	
}

Submission Info

Submission Time
Task C - 節制
User kiki33
Language Java (OpenJDK 1.7.0)
Score 40
Code Size 1562 Byte
Status MLE
Exec Time 1097 ms
Memory 278312 KB

Judge Result

Set Name Subtask1 Subtask2 Subtask3 Subtask4
Score / Max Score 10 / 10 30 / 30 0 / 60 0 / 1
Status
AC × 25
AC × 25
AC × 52
MLE × 34
AC × 49
MLE × 50
Set Name Test Cases
Subtask1 sample_1.txt, sample_2.txt, sample_3.txt, 01_010.txt, 01_011.txt, 01_020.txt, 01_021.txt, 01_100.txt, 01_101.txt, 01_110.txt, 01_111.txt, 01_200.txt, 01_201.txt, 01_220.txt, 01_221.txt, 01_random01.txt, 01_random02.txt, 01_random03.txt, 01_random04.txt, 01_random05.txt, 01_random06.txt, 01_random07.txt, 01_random08.txt, 01_random09.txt, 01_random10.txt
Subtask2 sample_1.txt, sample_2.txt, sample_3.txt, 02_010.txt, 02_011.txt, 02_020.txt, 02_021.txt, 02_100.txt, 02_101.txt, 02_110.txt, 02_111.txt, 02_200.txt, 02_201.txt, 02_220.txt, 02_221.txt, 02_random01.txt, 02_random02.txt, 02_random03.txt, 02_random04.txt, 02_random05.txt, 02_random06.txt, 02_random07.txt, 02_random08.txt, 02_random09.txt, 02_random10.txt
Subtask3 sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, 01_010.txt, 01_011.txt, 01_020.txt, 01_021.txt, 01_100.txt, 01_101.txt, 01_110.txt, 01_111.txt, 01_200.txt, 01_201.txt, 01_220.txt, 01_221.txt, 01_random01.txt, 01_random02.txt, 01_random03.txt, 01_random04.txt, 01_random05.txt, 01_random06.txt, 01_random07.txt, 01_random08.txt, 01_random09.txt, 01_random10.txt, 02_010.txt, 02_011.txt, 02_020.txt, 02_021.txt, 02_100.txt, 02_101.txt, 02_110.txt, 02_111.txt, 02_200.txt, 02_201.txt, 02_220.txt, 02_221.txt, 02_random01.txt, 02_random02.txt, 02_random03.txt, 02_random04.txt, 02_random05.txt, 02_random06.txt, 02_random07.txt, 02_random08.txt, 02_random09.txt, 02_random10.txt, 03_010.txt, 03_011.txt, 03_012.txt, 03_020.txt, 03_021.txt, 03_022.txt, 03_100.txt, 03_101.txt, 03_102.txt, 03_110.txt, 03_111.txt, 03_112.txt, 03_200.txt, 03_201.txt, 03_202.txt, 03_220.txt, 03_221.txt, 03_222.txt, 03_random01.txt, 03_random02.txt, 03_random03.txt, 03_random04.txt, 03_random05.txt, 03_random06.txt, 03_random07.txt, 03_random08.txt, 03_random09.txt, 03_random10.txt, 03_random11.txt, 03_random12.txt, 03_random13.txt, 03_random14.txt, 03_random15.txt, 03_random16.txt, 03_random17.txt, 03_random18.txt, 03_random19.txt, 03_random20.txt
Subtask4 01_010.txt, 01_011.txt, 01_020.txt, 01_021.txt, 01_100.txt, 01_101.txt, 01_110.txt, 01_111.txt, 01_200.txt, 01_201.txt, 01_220.txt, 01_221.txt, 01_random01.txt, 01_random02.txt, 01_random03.txt, 01_random04.txt, 01_random05.txt, 01_random06.txt, 01_random07.txt, 01_random08.txt, 01_random09.txt, 01_random10.txt, 02_010.txt, 02_011.txt, 02_020.txt, 02_021.txt, 02_100.txt, 02_101.txt, 02_110.txt, 02_111.txt, 02_200.txt, 02_201.txt, 02_220.txt, 02_221.txt, 02_random01.txt, 02_random02.txt, 02_random03.txt, 02_random04.txt, 02_random05.txt, 02_random06.txt, 02_random07.txt, 02_random08.txt, 02_random09.txt, 02_random10.txt, 03_010.txt, 03_011.txt, 03_012.txt, 03_020.txt, 03_021.txt, 03_022.txt, 03_100.txt, 03_101.txt, 03_102.txt, 03_110.txt, 03_111.txt, 03_112.txt, 03_200.txt, 03_201.txt, 03_202.txt, 03_220.txt, 03_221.txt, 03_222.txt, 03_random01.txt, 03_random02.txt, 03_random03.txt, 03_random04.txt, 03_random05.txt, 03_random06.txt, 03_random07.txt, 03_random08.txt, 03_random09.txt, 03_random10.txt, 03_random11.txt, 03_random12.txt, 03_random13.txt, 03_random14.txt, 03_random15.txt, 03_random16.txt, 03_random17.txt, 03_random18.txt, 03_random19.txt, 03_random20.txt, 04_010.txt, 04_011.txt, 04_020.txt, 04_021.txt, 04_100.txt, 04_101.txt, 04_110.txt, 04_111.txt, 04_200.txt, 04_201.txt, 04_220.txt, 04_221.txt, 04_random01.txt, 04_random02.txt, 04_random03.txt, 04_random04.txt, 04_random05.txt
Case Name Status Exec Time Memory
01_010.txt AC 498 ms 34996 KB
01_011.txt AC 547 ms 53036 KB
01_020.txt AC 535 ms 48280 KB
01_021.txt AC 522 ms 42904 KB
01_100.txt AC 472 ms 28332 KB
01_101.txt AC 507 ms 42384 KB
01_110.txt AC 509 ms 39344 KB
01_111.txt AC 503 ms 41652 KB
01_200.txt AC 508 ms 42896 KB
01_201.txt AC 542 ms 52016 KB
01_220.txt AC 474 ms 28080 KB
01_221.txt AC 547 ms 51136 KB
01_random01.txt AC 461 ms 25772 KB
01_random02.txt AC 583 ms 72244 KB
01_random03.txt AC 461 ms 25012 KB
01_random04.txt AC 527 ms 48820 KB
01_random05.txt AC 468 ms 28596 KB
01_random06.txt AC 506 ms 43180 KB
01_random07.txt AC 465 ms 24852 KB
01_random08.txt AC 530 ms 48816 KB
01_random09.txt AC 550 ms 54708 KB
01_random10.txt AC 497 ms 39220 KB
02_010.txt AC 452 ms 23216 KB
02_011.txt AC 448 ms 23208 KB
02_020.txt AC 449 ms 23216 KB
02_021.txt AC 454 ms 23216 KB
02_100.txt AC 451 ms 23220 KB
02_101.txt AC 452 ms 23200 KB
02_110.txt AC 450 ms 23216 KB
02_111.txt AC 450 ms 23216 KB
02_200.txt AC 451 ms 23224 KB
02_201.txt AC 447 ms 23092 KB
02_220.txt AC 452 ms 23216 KB
02_221.txt AC 457 ms 23216 KB
02_random01.txt AC 466 ms 23136 KB
02_random02.txt AC 460 ms 23208 KB
02_random03.txt AC 450 ms 23220 KB
02_random04.txt AC 451 ms 23216 KB
02_random05.txt AC 456 ms 23344 KB
02_random06.txt AC 452 ms 23216 KB
02_random07.txt AC 469 ms 23220 KB
02_random08.txt AC 458 ms 23212 KB
02_random09.txt AC 450 ms 23220 KB
02_random10.txt AC 456 ms 23088 KB
03_010.txt MLE 1016 ms 266804 KB
03_011.txt MLE 1009 ms 267828 KB
03_012.txt MLE 1036 ms 267692 KB
03_020.txt MLE 1030 ms 268464 KB
03_021.txt MLE 1020 ms 262956 KB
03_022.txt MLE 1010 ms 269844 KB
03_100.txt MLE 1046 ms 275764 KB
03_101.txt AC 1045 ms 244456 KB
03_102.txt MLE 1019 ms 267796 KB
03_110.txt MLE 1039 ms 271380 KB
03_111.txt MLE 1020 ms 273408 KB
03_112.txt MLE 1014 ms 269604 KB
03_200.txt MLE 1023 ms 270004 KB
03_201.txt MLE 1026 ms 265772 KB
03_202.txt MLE 1024 ms 264880 KB
03_220.txt MLE 1009 ms 267816 KB
03_221.txt MLE 1045 ms 268968 KB
03_222.txt MLE 1028 ms 273556 KB
03_random01.txt MLE 1011 ms 267152 KB
03_random02.txt AC 916 ms 209680 KB
03_random03.txt MLE 1014 ms 273972 KB
03_random04.txt MLE 1049 ms 268976 KB
03_random05.txt MLE 1066 ms 268820 KB
03_random06.txt MLE 1018 ms 269356 KB
03_random07.txt MLE 1016 ms 269488 KB
03_random08.txt MLE 1010 ms 268532 KB
03_random09.txt MLE 1048 ms 268716 KB
03_random10.txt AC 708 ms 124724 KB
03_random11.txt MLE 1025 ms 271024 KB
03_random12.txt MLE 1010 ms 266548 KB
03_random13.txt MLE 1046 ms 267824 KB
03_random14.txt MLE 1020 ms 266288 KB
03_random15.txt AC 869 ms 193716 KB
03_random16.txt MLE 1013 ms 268700 KB
03_random17.txt MLE 1017 ms 268992 KB
03_random18.txt MLE 1039 ms 268844 KB
03_random19.txt MLE 1001 ms 268436 KB
03_random20.txt AC 538 ms 51348 KB
04_010.txt MLE 1035 ms 275896 KB
04_011.txt MLE 1026 ms 271024 KB
04_020.txt MLE 1041 ms 266924 KB
04_021.txt MLE 1019 ms 267548 KB
04_100.txt MLE 1034 ms 267188 KB
04_101.txt MLE 1030 ms 272820 KB
04_110.txt MLE 1025 ms 265008 KB
04_111.txt MLE 1097 ms 278060 KB
04_200.txt MLE 1037 ms 272048 KB
04_201.txt MLE 1010 ms 268468 KB
04_220.txt MLE 1035 ms 265268 KB
04_221.txt MLE 1050 ms 266464 KB
04_random01.txt MLE 1021 ms 264880 KB
04_random02.txt MLE 1030 ms 268596 KB
04_random03.txt MLE 1069 ms 269096 KB
04_random04.txt MLE 1052 ms 278312 KB
04_random05.txt MLE 1019 ms 268204 KB
sample_1.txt AC 451 ms 23220 KB
sample_2.txt AC 453 ms 23224 KB
sample_3.txt AC 447 ms 23220 KB
sample_4.txt MLE 1026 ms 273812 KB