結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー anonymouslyanonymously
提出日時 2023-05-19 21:49:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 712 bytes
コンパイル時間 2,240 ms
コンパイル使用メモリ 166,008 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-22 23:48:45
合計ジャッジ時間 8,378 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 154 ms
4,380 KB
testcase_08 AC 30 ms
4,380 KB
testcase_09 AC 91 ms
4,380 KB
testcase_10 AC 89 ms
4,384 KB
testcase_11 AC 104 ms
4,380 KB
testcase_12 AC 138 ms
4,376 KB
testcase_13 AC 91 ms
4,380 KB
testcase_14 AC 77 ms
4,380 KB
testcase_15 AC 198 ms
4,380 KB
testcase_16 AC 201 ms
4,380 KB
testcase_17 AC 243 ms
4,380 KB
testcase_18 AC 245 ms
4,376 KB
testcase_19 AC 243 ms
4,384 KB
testcase_20 AC 243 ms
4,380 KB
testcase_21 AC 245 ms
4,376 KB
testcase_22 AC 243 ms
4,380 KB
testcase_23 AC 244 ms
4,376 KB
testcase_24 AC 243 ms
4,376 KB
testcase_25 AC 244 ms
4,376 KB
testcase_26 AC 244 ms
4,376 KB
testcase_27 AC 214 ms
4,380 KB
testcase_28 AC 225 ms
4,380 KB
testcase_29 AC 205 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
	//最初, i=1,2,…,M それぞれに対して, 色 i の魂が N 個中 Ai個ある.
	unsigned long n;
	size_t m;
	cin>>n>>m;
	vector<long> a(m);
	long soulPower=0;
	for(size_t i=0;i<m;i++){
		cin>>a.at(i);
		soulPower+=(a.at(i)*a.at(i));
	}
	size_t q;
	cin>>q;
	while(q--){
		//色Cである魂のうち, K個は本当は色Dである.
		size_t c,d;
		long k;
		cin>>c>>k>>d;
		//ソウルパワー変化
		//a[c-1]⇒a[c-1]-k
		long b=a.at(c-1)-k;
		soulPower+=(b*b-a.at(c-1)*a.at(c-1));
		a.at(c-1)=b;
		//a[d-1]⇒a[d-1]+k
		b=a.at(d-1)+k;
		soulPower+=(b*b-a.at(d-1)*a.at(d-1));
		a.at(d-1)=b;
		cout<<soulPower<<endl;
	}
	return EXIT_SUCCESS;	
}
0