結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー chro_96
提出日時 2023-05-19 21:29:07
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 654 bytes
コンパイル時間 1,573 ms
コンパイル使用メモリ 28,416 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-18 02:17:40
合計ジャッジ時間 5,022 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

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