結果

問題 No.1546 [Cherry 2nd Tune D] 思ったよりも易しくない
ユーザー kotatsugamekotatsugame
提出日時 2021-06-11 22:04:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 575 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 653 ms
コンパイル使用メモリ 69,760 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-05-08 17:49:32
合計ジャッジ時間 21,011 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 203 ms
5,376 KB
testcase_14 AC 524 ms
7,808 KB
testcase_15 AC 272 ms
5,504 KB
testcase_16 AC 259 ms
5,632 KB
testcase_17 AC 193 ms
5,376 KB
testcase_18 AC 364 ms
6,400 KB
testcase_19 AC 347 ms
6,272 KB
testcase_20 AC 422 ms
7,040 KB
testcase_21 AC 17 ms
5,376 KB
testcase_22 AC 369 ms
6,400 KB
testcase_23 AC 307 ms
6,016 KB
testcase_24 AC 62 ms
5,376 KB
testcase_25 AC 544 ms
8,064 KB
testcase_26 AC 568 ms
8,192 KB
testcase_27 AC 266 ms
5,632 KB
testcase_28 AC 575 ms
8,192 KB
testcase_29 AC 570 ms
8,064 KB
testcase_30 AC 565 ms
8,192 KB
testcase_31 AC 568 ms
8,192 KB
testcase_32 AC 564 ms
8,192 KB
testcase_33 AC 570 ms
8,192 KB
testcase_34 AC 569 ms
8,192 KB
testcase_35 AC 564 ms
8,192 KB
testcase_36 AC 562 ms
8,192 KB
testcase_37 AC 568 ms
8,192 KB
testcase_38 AC 565 ms
8,192 KB
testcase_39 AC 555 ms
8,192 KB
testcase_40 AC 568 ms
8,192 KB
testcase_41 AC 564 ms
8,192 KB
testcase_42 AC 568 ms
8,192 KB
testcase_43 AC 498 ms
8,320 KB
testcase_44 AC 495 ms
8,192 KB
testcase_45 AC 492 ms
8,192 KB
testcase_46 AC 492 ms
8,192 KB
testcase_47 AC 500 ms
8,064 KB
testcase_48 AC 574 ms
8,192 KB
testcase_49 AC 562 ms
8,192 KB
testcase_50 AC 2 ms
5,376 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
int N;
long T[3<<17],v[3<<17];
main()
{
	cin>>N;
	mint n=0;
	for(int i=0;i<N;i++)
	{
		cin>>T[i]>>v[i];
		n+=T[i];
	}
	mint p=0,ans=0;
	for(int i=0;i<N;i++)
	{
		mint now;
		now-=n*p*(p+1)*(2*p+1)/6;
		now-=(n+1)*p*(p+1)/2;
		now+=p*p*(p+1)*(p+1)/4;
		p+=T[i];
		now+=n*p*(p+1)*(2*p+1)/6;
		now+=(n+1)*p*(p+1)/2;
		now-=p*p*(p+1)*(p+1)/4;
		ans+=now*v[i];
	}
	cout<<(ans/2).val()<<endl;
}
0