結果
問題 | No.1279 Array Battle |
ユーザー | bluemegane |
提出日時 | 2020-11-07 09:19:00 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 1,714 ms / 2,000 ms |
コード長 | 1,707 bytes |
コンパイル時間 | 1,940 ms |
コンパイル使用メモリ | 68,260 KB |
実行使用メモリ | 30,176 KB |
最終ジャッジ日時 | 2023-09-29 20:20:05 |
合計ジャッジ時間 | 12,226 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 62 ms
21,520 KB |
testcase_01 | AC | 62 ms
23,608 KB |
testcase_02 | AC | 61 ms
21,680 KB |
testcase_03 | AC | 60 ms
21,608 KB |
testcase_04 | AC | 61 ms
21,680 KB |
testcase_05 | AC | 61 ms
21,560 KB |
testcase_06 | AC | 61 ms
21,544 KB |
testcase_07 | AC | 60 ms
21,556 KB |
testcase_08 | AC | 63 ms
21,676 KB |
testcase_09 | AC | 64 ms
21,492 KB |
testcase_10 | AC | 63 ms
21,560 KB |
testcase_11 | AC | 63 ms
23,548 KB |
testcase_12 | AC | 80 ms
27,856 KB |
testcase_13 | AC | 214 ms
27,880 KB |
testcase_14 | AC | 211 ms
25,800 KB |
testcase_15 | AC | 1,698 ms
28,100 KB |
testcase_16 | AC | 1,699 ms
28,064 KB |
testcase_17 | AC | 1,714 ms
30,176 KB |
testcase_18 | AC | 1,708 ms
28,000 KB |
testcase_19 | AC | 1,699 ms
28,060 KB |
ソースコード
using System.Linq; using System.Collections.Generic; using System; public static class Permi { public static IEnumerable<IEnumerable<T>> Perm<T>(this IEnumerable<T> items, int? k = null) { if (k == null) k = items.Count(); if (k == 0) yield return Enumerable.Empty<T>(); else { var i = 0; foreach (var x in items) { var xs = items.Where((_, index) => i != index); foreach (var c in Perm(xs, k - 1)) yield return c.Before(x); i++; } } } public static IEnumerable<T> Before<T>(this IEnumerable<T> items, T first) { yield return first; foreach (var i in items) yield return i; } } public class hello { static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); line = Console.ReadLine().Trim().Split(' '); var b = Array.ConvertAll(line, int.Parse); getAns(n, a, b); } static int calc(int n, int[] a, int[] b) { var res = 0; for (int i = 0; i < n; i++) { if (a[i] > b[i]) res += a[i] - b[i]; } return res; } static void getAns(int n, int[] a, int[] b) { var count = 0; var maxpoint = -1; foreach (var x in a.Perm(n)) { var a2 = x.ToArray(); var w = calc(n, a2, b); if (w > maxpoint) { maxpoint = w; count = 1; } else if (w == maxpoint) count++; } Console.WriteLine(count); } }