結果
問題 |
No.2329 Nafmo、イカサマをする
|
ユーザー |
|
提出日時 | 2023-10-16 20:44:23 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,104 bytes |
コンパイル時間 | 2,592 ms |
コンパイル使用メモリ | 105,728 KB |
実行使用メモリ | 30,848 KB |
最終ジャッジ日時 | 2024-09-16 22:16:49 |
合計ジャッジ時間 | 6,225 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 26 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static long[] NList => ReadLine().Split().Select(long.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, m, k) = (c[0], c[1], c[2]); var a = NList; var set = new HashSet<long>(); for (var i = 0; i <= n; ++i) for (var j = 0; j <= n; ++j) for (var p = 0; p <= n; ++p) { var ai = i == n ? 0 : a[i]; var aj = j == n ? 0 : a[j]; var ap = p == n ? 0 : a[p]; set.Add(ai + aj + ap); } var list = new List<long>(set); list.Sort(); var pos = list.Count - 1; var ans = 0L; for (var i = 0; i < list.Count; ++i) { while (pos >= 0 && list[i] + list[pos] > m) --pos; if (pos >= 0) ans = Math.Max(ans, list[i] + list[pos]); } WriteLine(ans); } }