結果

問題 No.1265 Balloon Survival
ユーザー keymoonkeymoon
提出日時 2020-10-23 23:42:10
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 520 ms / 2,000 ms
コード長 1,295 bytes
コンパイル時間 3,262 ms
コンパイル使用メモリ 104,940 KB
実行使用メモリ 50,612 KB
最終ジャッジ日時 2023-09-28 19:01:18
合計ジャッジ時間 13,446 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
23,060 KB
testcase_01 AC 77 ms
22,884 KB
testcase_02 AC 73 ms
24,848 KB
testcase_03 AC 82 ms
22,824 KB
testcase_04 AC 83 ms
22,968 KB
testcase_05 AC 82 ms
22,760 KB
testcase_06 AC 81 ms
22,768 KB
testcase_07 AC 81 ms
22,872 KB
testcase_08 AC 82 ms
22,812 KB
testcase_09 AC 81 ms
20,768 KB
testcase_10 AC 81 ms
20,788 KB
testcase_11 AC 82 ms
22,888 KB
testcase_12 AC 81 ms
22,804 KB
testcase_13 AC 81 ms
22,940 KB
testcase_14 AC 116 ms
23,484 KB
testcase_15 AC 105 ms
23,108 KB
testcase_16 AC 89 ms
24,888 KB
testcase_17 AC 270 ms
37,480 KB
testcase_18 AC 95 ms
22,776 KB
testcase_19 AC 93 ms
22,768 KB
testcase_20 AC 114 ms
21,348 KB
testcase_21 AC 161 ms
27,012 KB
testcase_22 AC 131 ms
25,888 KB
testcase_23 AC 137 ms
28,048 KB
testcase_24 AC 501 ms
50,592 KB
testcase_25 AC 512 ms
48,488 KB
testcase_26 AC 485 ms
50,536 KB
testcase_27 AC 487 ms
50,612 KB
testcase_28 AC 503 ms
48,512 KB
testcase_29 AC 496 ms
50,512 KB
testcase_30 AC 492 ms
50,604 KB
testcase_31 AC 516 ms
48,652 KB
testcase_32 AC 520 ms
48,472 KB
testcase_33 AC 500 ms
48,504 KB
testcase_34 AC 83 ms
22,888 KB
testcase_35 AC 82 ms
22,820 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        long[][] pts = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();

        int res = 0;
        HashSet<int> remain = new HashSet<int>(Enumerable.Range(0, n));
        foreach (var item in Enumerable.Range(0, n - 1).SelectMany(x => Enumerable.Range(x + 1, n - x - 1).Select(y => new Tuple<int, int>(x, y))).OrderBy(x => GetDist(pts[x.Item1], pts[x.Item2])))
        {
            var i = item.Item1;
            var j = item.Item2;
            if (remain.Contains(i) && remain.Contains(j))
            {
                if (i != 0) remain.Remove(i);
                else res++;
                remain.Remove(j);
            }
        }

        Console.WriteLine(res);
    }

    static long GetDist(long[] a, long[] b)
    {
        var dy = a[0] - b[0];
        var dx = a[1] - b[1];
        return dy * dy + dx * dx;
    }
}
0