結果

問題 No.1430 Coup de Coupon
ユーザー 小野寺健小野寺健
提出日時 2021-05-20 12:18:00
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,544 bytes
コンパイル時間 3,808 ms
コンパイル使用メモリ 80,304 KB
実行使用メモリ 185,816 KB
最終ジャッジ日時 2024-04-18 14:01:48
合計ジャッジ時間 16,003 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
53,032 KB
testcase_01 AC 126 ms
53,924 KB
testcase_02 AC 127 ms
53,968 KB
testcase_03 AC 227 ms
57,472 KB
testcase_04 AC 244 ms
58,196 KB
testcase_05 AC 236 ms
58,176 KB
testcase_06 AC 707 ms
185,308 KB
testcase_07 WA -
testcase_08 AC 298 ms
58,704 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class No1430 {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int C = scan.nextInt();
		List<Integer> P = new ArrayList<Integer>();
		for (int i=0; i < N; i++) {
			P.add(scan.nextInt());
		}
		Collections.sort(P, Collections.reverseOrder());
		List<Integer> TY = new ArrayList<Integer>();
		List<Integer> TP = new ArrayList<Integer>();
		for (int i=0; i < C; i++) {
			int T = scan.nextInt();
			int X = scan.nextInt();
			if (T == 1) {
				TY.add(X);
			} else {
				TP.add(X);
			}
		}
		scan.close();
		Collections.sort(TY, Collections.reverseOrder());
		Collections.sort(TP, Collections.reverseOrder());
		int L = TY.size();
		int[][] DP = new int[N+1][L+1];
		for (int i=0; i <= N; i++) {
			Arrays.fill(DP[i], Integer.MAX_VALUE);
		}
		DP[0][0] = 0;
		for (int i=0; i < N; i++) {
			for (int j=0; j <= L; j++) {
				int price = P.get(i);
				int cost;
				if (i-j < 0) {
					cost = 0;
				} else if (i-j < TP.size()) {
					cost = price * (100 - TP.get(i-j)) / 100;
				} else {
					cost = price;
				}
				DP[i+1][j] = Math.min(DP[i+1][j], DP[i][j] + cost);
				if (j < L) {
					cost = price - Math.min(price, TY.get(j));
					DP[i+1][j+1] = Math.min(DP[i+1][j+1], DP[i][j] + cost);
				}
			}
		}
		int min = Integer.MAX_VALUE;
		for (int j=0; j <=L; j++) {
			min = Math.min(min, DP[N][j]);
		}
		System.out.println(min);
	}
}
0