結果

問題 No.1619 Coccinellidae
ユーザー さかぽんさかぽん
提出日時 2021-07-22 22:31:35
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 1,023 bytes
コンパイル時間 3,162 ms
コンパイル使用メモリ 107,636 KB
実行使用メモリ 33,756 KB
最終ジャッジ日時 2023-09-24 17:48:05
合計ジャッジ時間 6,240 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
21,776 KB
testcase_01 AC 88 ms
27,308 KB
testcase_02 AC 95 ms
30,352 KB
testcase_03 AC 67 ms
23,804 KB
testcase_04 AC 94 ms
28,272 KB
testcase_05 AC 88 ms
28,264 KB
testcase_06 AC 66 ms
23,784 KB
testcase_07 AC 82 ms
24,096 KB
testcase_08 AC 83 ms
27,108 KB
testcase_09 AC 67 ms
21,780 KB
testcase_10 AC 79 ms
23,728 KB
testcase_11 AC 86 ms
28,132 KB
testcase_12 AC 67 ms
21,760 KB
testcase_13 AC 93 ms
30,128 KB
testcase_14 AC 96 ms
33,756 KB
testcase_15 AC 66 ms
21,872 KB
testcase_16 AC 66 ms
21,776 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 D
{
	static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
	static (int, int) Read2() { var a = Read(); return (a[0], a[1]); }
	static long[] ReadL() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	static (long, long, long) Read3L() { var a = ReadL(); return (a[0], a[1], a[2]); }
	static void Main() => Console.WriteLine(Solve());
	static object Solve()
	{
		var (n, m, k) = Read3L();

		var max = m - (n - 1) * (n - 2) / 2;
		var st = new Stack<long>(Enumerable.Range(0, (int)n - 1).Select(i => (long)i));
		st.Push(max);

		var r = Array.ConvertAll(new bool[n], _ => -1L);

		for (int i = 0; i < n && k > 0; i++)
		{
			if (k <= n - 1 - i)
			{
				r[n - 1 - k] = st.Pop();
				k = 0;
			}
			else
			{
				r[i] = st.Pop();
				k -= n - 1 - i;
			}
		}

		var q = new Queue<long>(st.Reverse());

		for (int i = 0; i < n; i++)
			if (r[i] == -1)
				r[i] = q.Dequeue();

		return string.Join("\n", r);
	}
}
0