結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー ks2mks2m
提出日時 2023-05-19 21:29:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 604 ms / 2,000 ms
コード長 982 bytes
コンパイル時間 2,706 ms
コンパイル使用メモリ 77,304 KB
実行使用メモリ 54,436 KB
最終ジャッジ日時 2024-05-10 05:10:59
合計ジャッジ時間 16,013 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
37,072 KB
testcase_01 AC 52 ms
37,212 KB
testcase_02 AC 98 ms
38,912 KB
testcase_03 AC 60 ms
37,500 KB
testcase_04 AC 108 ms
38,928 KB
testcase_05 AC 103 ms
39,096 KB
testcase_06 AC 114 ms
39,432 KB
testcase_07 AC 439 ms
50,152 KB
testcase_08 AC 210 ms
47,344 KB
testcase_09 AC 325 ms
50,492 KB
testcase_10 AC 278 ms
44,736 KB
testcase_11 AC 353 ms
49,036 KB
testcase_12 AC 452 ms
53,888 KB
testcase_13 AC 339 ms
51,124 KB
testcase_14 AC 325 ms
48,228 KB
testcase_15 AC 485 ms
50,308 KB
testcase_16 AC 424 ms
46,928 KB
testcase_17 AC 540 ms
53,992 KB
testcase_18 AC 542 ms
53,984 KB
testcase_19 AC 533 ms
53,928 KB
testcase_20 AC 547 ms
54,436 KB
testcase_21 AC 604 ms
54,028 KB
testcase_22 AC 582 ms
53,580 KB
testcase_23 AC 591 ms
53,484 KB
testcase_24 AC 551 ms
53,716 KB
testcase_25 AC 545 ms
53,696 KB
testcase_26 AC 552 ms
53,704 KB
testcase_27 AC 488 ms
53,444 KB
testcase_28 AC 505 ms
52,616 KB
testcase_29 AC 428 ms
45,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		long[] a = new long[m];
		long ans = 0;
		for (int i = 0; i < m; i++) {
			a[i] = Integer.parseInt(sa[i]);
			ans += a[i] * a[i];
		}

		int q = Integer.parseInt(br.readLine());
		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			sa = br.readLine().split(" ");
			int c = Integer.parseInt(sa[0]) - 1;
			int k = Integer.parseInt(sa[1]);
			int d = Integer.parseInt(sa[2]) - 1;

			ans -= a[c] * a[c];
			ans -= a[d] * a[d];
			a[c] -= k;
			a[d] += k;
			ans += a[c] * a[c];
			ans += a[d] * a[d];
			pw.println(ans);
		}
		pw.flush();
		br.close();
	}
}
0