結果
| 問題 |
No.2560 A_1 < A_2 < ... < A_N
|
| コンテスト | |
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2025-02-18 15:10:25 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 323 ms / 2,000 ms |
| コード長 | 1,769 bytes |
| コンパイル時間 | 2,719 ms |
| コンパイル使用メモリ | 116,740 KB |
| 実行使用メモリ | 36,608 KB |
| 最終ジャッジ日時 | 2025-02-18 15:10:34 |
| 合計ジャッジ時間 | 6,479 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 15 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("3");
WillReturn.Add("4 10");
WillReturn.Add("3 5");
WillReturn.Add("3 9");
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
long[] wkArr = { };
Action<string> SplitAct = pStr =>
wkArr = pStr.Split(' ').Select(pX => long.Parse(pX)).ToArray();
foreach (string EachStr in InputList.Skip(1)) {
SplitAct(EachStr);
long N = wkArr[0];
long X = wkArr[1];
string Result = Solve(N, X);
Console.WriteLine(Result);
}
}
static string Solve(long pN, long pX)
{
var AnswerList = new List<long>();
for (long I = 1; I <= pN; I++) {
AnswerList.Add(I);
}
long SumVal = AnswerList.Sum();
if (SumVal > pX) {
return "-1";
}
long Rest = pX - SumVal;
AnswerList[AnswerList.Count - 1] += Rest;
return LongEnumJoin(" ", AnswerList);
}
// セパレータとLong型の列挙を引数として、結合したstringを返す
static string LongEnumJoin(string pSeparater, IEnumerable<long> pEnum)
{
string[] StrArr = Array.ConvertAll(pEnum.ToArray(), pX => pX.ToString());
return string.Join(pSeparater, StrArr);
}
}
aketijyuuzou