結果

問題 No.723 2つの数の和
ユーザー 抹茶アイス抹茶アイス
提出日時 2023-08-01 17:12:14
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,291 bytes
コンパイル時間 9,278 ms
コンパイル使用メモリ 169,092 KB
実行使用メモリ 188,948 KB
最終ジャッジ日時 2024-04-19 16:26:21
合計ジャッジ時間 16,296 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
30,204 KB
testcase_01 AC 53 ms
30,080 KB
testcase_02 AC 52 ms
30,068 KB
testcase_03 AC 615 ms
38,400 KB
testcase_04 AC 376 ms
40,828 KB
testcase_05 AC 169 ms
39,552 KB
testcase_06 AC 952 ms
39,552 KB
testcase_07 AC 212 ms
34,936 KB
testcase_08 AC 289 ms
35,432 KB
testcase_09 AC 737 ms
41,216 KB
testcase_10 AC 165 ms
35,072 KB
testcase_11 AC 79 ms
32,000 KB
testcase_12 AC 311 ms
36,856 KB
testcase_13 AC 96 ms
41,472 KB
testcase_14 AC 76 ms
33,780 KB
testcase_15 AC 79 ms
35,072 KB
testcase_16 AC 93 ms
37,376 KB
testcase_17 AC 87 ms
39,296 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 56 ms
29,692 KB
testcase_21 AC 51 ms
29,824 KB
testcase_22 AC 56 ms
30,080 KB
testcase_23 AC 946 ms
41,576 KB
testcase_24 AC 76 ms
188,948 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (103 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

namespace yukicoder
{
    public class Program
    {
        public static void Main()
        {
            var line = Console.ReadLine().Split(' ');
            var n = int.Parse(line[0]);
            var x = int.Parse(line[1]);
            var a = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
            long sum = 0;
            var T = x % 2 == 0;
            Array.Sort(a);
            var t = 0;
            for(var i = 0; i < n; i++)
            {
                if ( T && a[i] == x / 2)
                {
                    t++;
                }
                else
                {
                    if (a[i] > x / 2)
                    {
                        break;
                    }
                    for (var j = n - 1; j >= 0; j--)
                    {
                        if (a[i] + a[j] == x)
                        {
                            sum += 2;
                        }
                        else if (a[i] + a[j] < x)
                        {
                            break;
                        }
                    }
                }
            }
            sum += t * t;
            Console.WriteLine(sum);
        }
    }
}
0