結果

問題 No.1430 Coup de Coupon
ユーザー さかぽんさかぽん
提出日時 2021-03-14 15:01:21
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,063 bytes
コンパイル時間 988 ms
コンパイル使用メモリ 108,160 KB
実行使用メモリ 21,832 KB
最終ジャッジ日時 2024-04-23 22:42:37
合計ジャッジ時間 3,096 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
19,200 KB
testcase_01 AC 37 ms
19,456 KB
testcase_02 AC 35 ms
19,328 KB
testcase_03 AC 42 ms
19,960 KB
testcase_04 AC 44 ms
21,376 KB
testcase_05 AC 45 ms
21,224 KB
testcase_06 AC 49 ms
21,776 KB
testcase_07 AC 51 ms
21,832 KB
testcase_08 AC 50 ms
21,788 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 AC 47 ms
21,300 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 39 ms
19,584 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Generic;
using System.Linq;

class B
{
	static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
	static (int t, int x) Read2() { var a = Read(); return (a[0], a[1]); }
	static void Main() => Console.WriteLine(Solve());
	static object Solve()
	{
		var (n, cc) = Read2();
		var ps = Array.ConvertAll(new bool[n], _ => int.Parse(Console.ReadLine()));
		var cs = Array.ConvertAll(new bool[cc], _ => Read2());

		ps = ps.OrderBy(x => -x).ToArray();
		var q1 = new Queue<int>(cs.Where(c => c.t == 1).Select(c => c.x).OrderBy(x => -x));
		var q2 = new Queue<int>(cs.Where(c => c.t == 2).Select(c => c.x).OrderBy(x => -x));

		var r = 0;
		foreach (var p in ps)
		{
			var (t1, t2) = (1 << 30, 1 << 30);
			if (q1.Any())
				t1 = Math.Max(0, p - q1.Peek());
			if (q2.Any())
				t2 = p - p / 100 * q2.Peek();

			if (t1 < t2)
			{
				q1.Dequeue();
				r += t1;
			}
			else
			{
				if (t2 == 1 << 30)
				{
					r += p;
				}
				else
				{
					q2.Dequeue();
					r += t2;
				}
			}
		}
		return r;
	}
}
0