結果

問題 No.1430 Coup de Coupon
ユーザー さかぽんさかぽん
提出日時 2021-03-14 16:24:46
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,125 bytes
コンパイル時間 940 ms
コンパイル使用メモリ 108,544 KB
実行使用メモリ 21,864 KB
最終ジャッジ日時 2024-04-23 23:44:24
合計ジャッジ時間 2,789 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
19,328 KB
testcase_01 AC 31 ms
19,328 KB
testcase_02 AC 31 ms
19,200 KB
testcase_03 AC 36 ms
19,960 KB
testcase_04 AC 39 ms
20,992 KB
testcase_05 AC 39 ms
20,964 KB
testcase_06 AC 43 ms
21,660 KB
testcase_07 AC 43 ms
21,580 KB
testcase_08 AC 43 ms
21,396 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 41 ms
21,168 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 34 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 (t1 > t2)
			{
				q2.Dequeue();
				r += t2;
			}
			else
			{
				if (t1 == 1 << 30)
				{
					r += p;
				}
				else
				{
					q2.Dequeue();
					r += t2;
				}
			}
		}
		return r;
	}
}
0