結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-07-03 10:28:26
言語 Ruby
(3.3.0)
結果
AC  
実行時間 459 ms / 2,000 ms
コード長 256 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 11,568 KB
実行使用メモリ 25,020 KB
最終ジャッジ日時 2023-09-24 07:29:29
合計ジャッジ時間 12,134 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,032 KB
testcase_01 AC 82 ms
15,040 KB
testcase_02 AC 86 ms
15,080 KB
testcase_03 AC 86 ms
15,148 KB
testcase_04 AC 87 ms
15,128 KB
testcase_05 AC 86 ms
15,272 KB
testcase_06 AC 86 ms
15,384 KB
testcase_07 AC 331 ms
21,044 KB
testcase_08 AC 135 ms
19,412 KB
testcase_09 AC 229 ms
21,136 KB
testcase_10 AC 218 ms
15,548 KB
testcase_11 AC 243 ms
20,356 KB
testcase_12 AC 302 ms
24,708 KB
testcase_13 AC 236 ms
21,172 KB
testcase_14 AC 208 ms
20,692 KB
testcase_15 AC 374 ms
20,588 KB
testcase_16 AC 383 ms
17,576 KB
testcase_17 AC 456 ms
24,916 KB
testcase_18 AC 459 ms
24,840 KB
testcase_19 AC 452 ms
24,660 KB
testcase_20 AC 454 ms
24,748 KB
testcase_21 AC 453 ms
24,944 KB
testcase_22 AC 454 ms
24,728 KB
testcase_23 AC 456 ms
24,956 KB
testcase_24 AC 456 ms
24,908 KB
testcase_25 AC 451 ms
24,724 KB
testcase_26 AC 454 ms
25,020 KB
testcase_27 AC 421 ms
24,272 KB
testcase_28 AC 439 ms
24,552 KB
testcase_29 AC 396 ms
15,268 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:7: warning: assigned but unused variable - n
Main.rb:7: warning: assigned but unused variable - m
Syntax OK

ソースコード

diff #

def f()
	return gets.split(" ").map{|e| e.to_i}
end
def g(xs)
	return xs.map{|e| e**2}.sum
end
n,m=f()
xs=f()
q=gets.to_i
sum=g(xs)
q.times{
	c,k,d=f()
	c-=1
	d-=1
	sum-=(xs[c]**2+xs[d]**2)
	xs[c],xs[d]=xs[c]-k,xs[d]+k
	sum+=(xs[c]**2+xs[d]**2)
	puts sum
}
0