結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー norikamenorikame
提出日時 2023-05-19 21:37:19
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 806 bytes
コンパイル時間 7,907 ms
コンパイル使用メモリ 304,640 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 23:41:12
合計ジャッジ時間 13,297 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 137 ms
4,380 KB
testcase_08 AC 27 ms
4,376 KB
testcase_09 AC 83 ms
4,376 KB
testcase_10 AC 82 ms
4,380 KB
testcase_11 AC 92 ms
4,376 KB
testcase_12 AC 123 ms
4,376 KB
testcase_13 AC 82 ms
4,380 KB
testcase_14 AC 73 ms
4,380 KB
testcase_15 AC 186 ms
4,376 KB
testcase_16 AC 185 ms
4,376 KB
testcase_17 AC 214 ms
4,380 KB
testcase_18 AC 217 ms
4,376 KB
testcase_19 AC 213 ms
4,380 KB
testcase_20 AC 222 ms
4,380 KB
testcase_21 AC 230 ms
4,380 KB
testcase_22 AC 220 ms
4,376 KB
testcase_23 AC 220 ms
4,380 KB
testcase_24 AC 213 ms
4,380 KB
testcase_25 AC 213 ms
4,376 KB
testcase_26 AC 218 ms
4,380 KB
testcase_27 AC 199 ms
4,376 KB
testcase_28 AC 199 ms
4,376 KB
testcase_29 AC 181 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

const int INF = (int)(1e9);

int main() {
	int n, m, q;
	cin >> n >> m;
	vector<int> a(m);
	rep(i, m) cin >> a[i];
	ll res = 0;
	rep(i, m) res += (ll)a[i] * a[i];
	cin >> q;
	rep(i, q) {
		int ci, ki, di;
		cin >> ci >> ki >> di;
		--ci; --di;
		res -= (ll)a[ci] * a[ci] + (ll)a[di] * a[di];
		a[ci] -= ki;
		a[di] += ki;
		res += (ll)a[ci] * a[ci] + (ll)a[di] * a[di];
		cout << res << endl;
	}
	return 0;
}
0