結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー 👑 chro_96chro_96
提出日時 2023-05-19 21:29:07
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 654 bytes
コンパイル時間 1,504 ms
コンパイル使用メモリ 27,968 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-22 23:33:42
合計ジャッジ時間 4,772 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,504 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 35 ms
4,380 KB
testcase_08 AC 9 ms
4,380 KB
testcase_09 AC 23 ms
4,384 KB
testcase_10 AC 20 ms
4,380 KB
testcase_11 AC 24 ms
4,384 KB
testcase_12 AC 33 ms
4,380 KB
testcase_13 AC 24 ms
4,384 KB
testcase_14 AC 20 ms
4,384 KB
testcase_15 AC 40 ms
4,388 KB
testcase_16 AC 42 ms
4,388 KB
testcase_17 AC 50 ms
4,384 KB
testcase_18 AC 53 ms
4,388 KB
testcase_19 AC 53 ms
4,388 KB
testcase_20 AC 52 ms
4,384 KB
testcase_21 AC 52 ms
4,384 KB
testcase_22 AC 52 ms
4,380 KB
testcase_23 AC 52 ms
4,380 KB
testcase_24 AC 54 ms
4,384 KB
testcase_25 AC 51 ms
4,384 KB
testcase_26 AC 51 ms
4,384 KB
testcase_27 AC 43 ms
4,384 KB
testcase_28 AC 47 ms
4,508 KB
testcase_29 AC 40 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int n = 0;
  int m = 0;
  long long a[100000] = {};
  int q = 0;
  int c = 0;
  long long k = 0LL;
  int d = 0;
  
  int res = 0;
  
  long long ans = 0LL;
  
  res = scanf("%d", &n);
  res = scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    res = scanf("%lld\n", a+i);
    ans += a[i]*a[i];
  }
  res = scanf("%d", &q);
  while (q > 0) {
    res = scanf("%d", &c);
    res = scanf("%lld", &k);
    res = scanf("%d", &d);
    c--;
    d--;
    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];
    printf("%lld\n", ans);
    q--;
  }
  
  return 0;
}
0