結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー kotatsugamekotatsugame
提出日時 2023-05-19 21:22:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 235 ms / 2,000 ms
コード長 365 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 63,260 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 23:24:23
合計ジャッジ時間 6,595 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 144 ms
4,376 KB
testcase_08 AC 26 ms
4,380 KB
testcase_09 AC 83 ms
4,376 KB
testcase_10 AC 84 ms
4,380 KB
testcase_11 AC 98 ms
4,376 KB
testcase_12 AC 123 ms
4,380 KB
testcase_13 AC 85 ms
4,376 KB
testcase_14 AC 72 ms
4,380 KB
testcase_15 AC 185 ms
4,376 KB
testcase_16 AC 188 ms
4,376 KB
testcase_17 AC 223 ms
4,376 KB
testcase_18 AC 225 ms
4,380 KB
testcase_19 AC 225 ms
4,380 KB
testcase_20 AC 221 ms
4,376 KB
testcase_21 AC 219 ms
4,376 KB
testcase_22 AC 217 ms
4,380 KB
testcase_23 AC 219 ms
4,376 KB
testcase_24 AC 224 ms
4,380 KB
testcase_25 AC 218 ms
4,380 KB
testcase_26 AC 235 ms
4,376 KB
testcase_27 AC 200 ms
4,376 KB
testcase_28 AC 206 ms
4,376 KB
testcase_29 AC 196 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
int N,M;
int A[1<<17];
int main()
{
	cin>>N>>M;
	long ans=0;
	for(int i=1;i<=M;i++)
	{
		cin>>A[i];
		ans+=(long)A[i]*A[i];
	}
	int Q;cin>>Q;
	for(;Q--;)
	{
		int c,k,d;cin>>c>>k>>d;
		ans-=(long)A[c]*A[c];
		ans-=(long)A[d]*A[d];
		A[c]-=k;
		A[d]+=k;
		ans+=(long)A[c]*A[c];
		ans+=(long)A[d]*A[d];
		cout<<ans<<"\n";
	}
}
0