結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー kanenistkanenist
提出日時 2023-05-26 12:50:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,484 ms / 2,000 ms
コード長 664 bytes
コンパイル時間 4,165 ms
コンパイル使用メモリ 70,732 KB
実行使用メモリ 71,412 KB
最終ジャッジ日時 2023-08-18 14:28:08
合計ジャッジ時間 39,470 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,508 KB
testcase_01 AC 122 ms
55,976 KB
testcase_02 AC 230 ms
59,064 KB
testcase_03 AC 192 ms
56,460 KB
testcase_04 AC 242 ms
59,192 KB
testcase_05 AC 248 ms
59,784 KB
testcase_06 AC 248 ms
60,036 KB
testcase_07 AC 1,149 ms
71,412 KB
testcase_08 AC 525 ms
60,492 KB
testcase_09 AC 835 ms
65,032 KB
testcase_10 AC 816 ms
64,568 KB
testcase_11 AC 901 ms
65,808 KB
testcase_12 AC 1,098 ms
69,840 KB
testcase_13 AC 858 ms
65,084 KB
testcase_14 AC 809 ms
65,176 KB
testcase_15 AC 1,263 ms
69,920 KB
testcase_16 AC 1,276 ms
69,784 KB
testcase_17 AC 1,484 ms
69,808 KB
testcase_18 AC 1,464 ms
69,676 KB
testcase_19 AC 1,461 ms
69,648 KB
testcase_20 AC 1,464 ms
69,888 KB
testcase_21 AC 1,454 ms
69,964 KB
testcase_22 AC 1,447 ms
70,472 KB
testcase_23 AC 1,441 ms
70,212 KB
testcase_24 AC 1,479 ms
69,556 KB
testcase_25 AC 1,458 ms
69,924 KB
testcase_26 AC 1,433 ms
69,472 KB
testcase_27 AC 1,386 ms
70,620 KB
testcase_28 AC 1,419 ms
70,776 KB
testcase_29 AC 1,263 ms
66,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int m = sc.nextInt();
    	long a[] = new long[m + 1];
    	for(int i = 1; i <= m; i++)a[i] = sc.nextInt();
    	int q = sc.nextInt();
    	long sum = 0;
    	for(int h = 1; h <= m; h++){
    		sum += a[h]*a[h];
    	}
    	for(int i = 0; i < q; i++){
    		
    		int a1 = sc.nextInt();
    		int b = sc.nextInt();
    		int c = sc.nextInt();
    		sum -= a[a1]*a[a1] + a[c] * a[c];
    		a[a1] -= b;
    		a[c] += b;
    		sum += a[a1]*a[a1] + a[c] * a[c];
    		System.out.println(sum);
    	}
    }
}
0