結果
| 問題 |
No.1095 Smallest Kadomatsu Subsequence
|
| コンテスト | |
| ユーザー |
yk1095
|
| 提出日時 | 2020-07-03 11:24:03 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,501 bytes |
| コンパイル時間 | 2,965 ms |
| コンパイル使用メモリ | 107,904 KB |
| 実行使用メモリ | 34,352 KB |
| 最終ジャッジ日時 | 2024-09-16 16:19:35 |
| 合計ジャッジ時間 | 5,516 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 TLE * 1 -- * 19 |
コンパイルメッセージ
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.Diagnostics;
using System.Linq;
namespace AtCoder.A
{
public class Program
{
public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }
private static object GetResult()
{
var N = ReadLong();
var A = ReadLongs();
var min = long.MaxValue;
for (var i = 0; i < N - 2; i++)
{
for (var j = i + 1; j < N - 1; j++)
{
for (var k = j + 1; k < N; k++)
{
var a = A[i];
var b = A[j];
var c = A[k];
if (a == b || b == c || c == a) continue;
if (b < a && b < c || b > a && b > c)
{
min = Math.Min(min, a + b + c);
}
}
}
}
return min == long.MaxValue ? -1 : min;
}
#region Console
public static string ReadText() { return Console.ReadLine(); }
public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
#endregion
}
}
yk1095