結果

問題 No.1430 Coup de Coupon
ユーザー さかぽん
提出日時 2021-03-14 16:24:46
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,125 bytes
コンパイル時間 1,187 ms
コンパイル使用メモリ 112,712 KB
実行使用メモリ 29,812 KB
最終ジャッジ日時 2024-11-06 06:08:54
合計ジャッジ時間 3,777 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
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