結果
問題 | No.2306 [Cherry 5th Tune C] ウソツキタマシイ |
ユーザー | tenten |
提出日時 | 2023-05-29 13:56:57 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 464 ms / 2,000 ms |
コード長 | 2,230 bytes |
コンパイル時間 | 2,683 ms |
コンパイル使用メモリ | 86,972 KB |
実行使用メモリ | 52,704 KB |
最終ジャッジ日時 | 2024-06-08 19:13:17 |
合計ジャッジ時間 | 15,402 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
36,780 KB |
testcase_01 | AC | 48 ms
36,720 KB |
testcase_02 | AC | 79 ms
38,296 KB |
testcase_03 | AC | 56 ms
37,072 KB |
testcase_04 | AC | 90 ms
38,464 KB |
testcase_05 | AC | 101 ms
38,968 KB |
testcase_06 | AC | 106 ms
39,120 KB |
testcase_07 | AC | 366 ms
49,772 KB |
testcase_08 | AC | 204 ms
44,584 KB |
testcase_09 | AC | 297 ms
47,476 KB |
testcase_10 | AC | 238 ms
46,092 KB |
testcase_11 | AC | 286 ms
47,024 KB |
testcase_12 | AC | 332 ms
50,008 KB |
testcase_13 | AC | 295 ms
47,284 KB |
testcase_14 | AC | 269 ms
45,912 KB |
testcase_15 | AC | 378 ms
50,604 KB |
testcase_16 | AC | 388 ms
50,460 KB |
testcase_17 | AC | 441 ms
51,740 KB |
testcase_18 | AC | 464 ms
52,492 KB |
testcase_19 | AC | 459 ms
52,204 KB |
testcase_20 | AC | 422 ms
52,276 KB |
testcase_21 | AC | 443 ms
52,184 KB |
testcase_22 | AC | 421 ms
50,868 KB |
testcase_23 | AC | 407 ms
51,804 KB |
testcase_24 | AC | 419 ms
51,828 KB |
testcase_25 | AC | 449 ms
51,692 KB |
testcase_26 | AC | 405 ms
52,704 KB |
testcase_27 | AC | 359 ms
47,160 KB |
testcase_28 | AC | 395 ms
51,760 KB |
testcase_29 | AC | 357 ms
51,016 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); long base = 0; long[] counts = new long[m]; for (int i = 0; i < m; i++) { counts[i] = sc.nextInt(); base += counts[i] * counts[i]; } int q = sc.nextInt(); StringBuilder sb = new StringBuilder(); while (q-- > 0) { int left = sc.nextInt() - 1; int k = sc.nextInt(); int right = sc.nextInt() - 1; base -= counts[left] * counts[left]; base -= counts[right] * counts[right]; counts[left] -= k; counts[right] += k; base += counts[left] * counts[left]; base += counts[right] * counts[right]; sb.append(base).append("\n"); } System.out.print(sb); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }