結果
問題 |
No.1095 Smallest Kadomatsu Subsequence
|
ユーザー |
![]() |
提出日時 | 2020-07-03 11:28:11 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,437 bytes |
コンパイル時間 | 2,482 ms |
コンパイル使用メモリ | 107,776 KB |
実行使用メモリ | 24,192 KB |
最終ジャッジ日時 | 2024-09-16 16:19:42 |
合計ジャッジ時間 | 5,439 ms |
ジャッジサーバーID (参考情報) |
judge3 / 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; long a, b, c; for (var i = 0; i < N - 2; i++) { a = A[i]; for (var j = i + 1; j < N - 1; j++) { b = A[j]; for (var k = j + 1; k < N; k++) { c = A[k]; 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 } }