結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー ks2mks2m
提出日時 2023-05-19 21:29:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 490 ms / 2,000 ms
コード長 982 bytes
コンパイル時間 4,461 ms
コンパイル使用メモリ 73,304 KB
実行使用メモリ 64,800 KB
最終ジャッジ日時 2023-08-22 23:33:36
合計ジャッジ時間 16,670 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,512 KB
testcase_01 AC 41 ms
49,364 KB
testcase_02 AC 77 ms
51,104 KB
testcase_03 AC 51 ms
50,588 KB
testcase_04 AC 86 ms
51,808 KB
testcase_05 AC 94 ms
52,384 KB
testcase_06 AC 93 ms
53,004 KB
testcase_07 AC 393 ms
60,096 KB
testcase_08 AC 199 ms
58,056 KB
testcase_09 AC 296 ms
61,156 KB
testcase_10 AC 247 ms
42,900 KB
testcase_11 AC 304 ms
45,092 KB
testcase_12 AC 388 ms
49,368 KB
testcase_13 AC 326 ms
47,656 KB
testcase_14 AC 269 ms
44,472 KB
testcase_15 AC 436 ms
46,176 KB
testcase_16 AC 418 ms
44,848 KB
testcase_17 AC 466 ms
49,952 KB
testcase_18 AC 490 ms
50,268 KB
testcase_19 AC 477 ms
49,892 KB
testcase_20 AC 470 ms
50,416 KB
testcase_21 AC 463 ms
50,188 KB
testcase_22 AC 490 ms
50,056 KB
testcase_23 AC 484 ms
51,172 KB
testcase_24 AC 474 ms
64,800 KB
testcase_25 AC 455 ms
63,472 KB
testcase_26 AC 468 ms
51,132 KB
testcase_27 AC 405 ms
62,236 KB
testcase_28 AC 473 ms
48,932 KB
testcase_29 AC 376 ms
57,444 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