結果

問題 No.1564 Sum of Products of Pairs
ユーザー kakel-san
提出日時 2024-03-14 23:07:51
言語 C#
(.NET 8.0.404)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 746 bytes
コンパイル時間 8,191 ms
コンパイル使用メモリ 167,120 KB
実行使用メモリ 184,024 KB
最終ジャッジ日時 2024-09-29 23:50:28
合計ジャッジ時間 13,330 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (100 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 static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray();
    static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var a = NList;
        Array.Sort(a);
        var ans = 0L;
        for (var i = 0; i < a.Length; i += 2)
        {
            ans += (long)a[i] * a[i + 1];
        }
        WriteLine(ans);
    }
}
0