結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー 👑 kakel-sankakel-san
提出日時 2023-07-29 20:11:55
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 265 ms / 2,000 ms
コード長 995 bytes
コンパイル時間 1,245 ms
コンパイル使用メモリ 107,520 KB
実行使用メモリ 42,496 KB
最終ジャッジ日時 2024-04-16 23:44:18
合計ジャッジ時間 9,834 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
18,944 KB
testcase_01 AC 32 ms
19,072 KB
testcase_02 AC 38 ms
19,968 KB
testcase_03 AC 38 ms
19,456 KB
testcase_04 AC 40 ms
20,096 KB
testcase_05 AC 38 ms
20,096 KB
testcase_06 AC 39 ms
20,096 KB
testcase_07 AC 181 ms
36,864 KB
testcase_08 AC 72 ms
27,520 KB
testcase_09 AC 126 ms
33,408 KB
testcase_10 AC 120 ms
28,800 KB
testcase_11 AC 136 ms
32,256 KB
testcase_12 AC 168 ms
36,736 KB
testcase_13 AC 128 ms
33,408 KB
testcase_14 AC 113 ms
30,848 KB
testcase_15 AC 217 ms
37,504 KB
testcase_16 AC 221 ms
36,736 KB
testcase_17 AC 258 ms
38,912 KB
testcase_18 AC 259 ms
38,784 KB
testcase_19 AC 258 ms
39,168 KB
testcase_20 AC 264 ms
39,168 KB
testcase_21 AC 257 ms
38,912 KB
testcase_22 AC 258 ms
39,040 KB
testcase_23 AC 260 ms
38,912 KB
testcase_24 AC 265 ms
39,040 KB
testcase_25 AC 260 ms
39,040 KB
testcase_26 AC 264 ms
39,040 KB
testcase_27 AC 213 ms
35,840 KB
testcase_28 AC 239 ms
42,496 KB
testcase_29 AC 211 ms
36,480 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 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[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, m) = (c[0], c[1]);
        var a = NList;
        var q = NN;
        var map = NArr(q);
        var ans = new long[q + 1];
        foreach (var ai in a) ans[0] += (long)ai * ai;
        for (var i = 0; i < q; ++i)
        {
            var x = map[i][0] - 1;
            var k = map[i][1];
            var y = map[i][2] - 1;
            ans[i + 1] = ans[i] + 2L * k * ((long)k - a[x] + a[y]);
            a[x] -= k;
            a[y] += k;
        }
        WriteLine(string.Join("\n", ans.Skip(1)));
    }
}
0