結果
問題 | No.1546 [Cherry 2nd Tune D] 思ったよりも易しくない |
ユーザー | kotatsugame |
提出日時 | 2021-06-11 22:04:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 594 ms / 2,000 ms |
コード長 | 491 bytes |
コンパイル時間 | 711 ms |
コンパイル使用メモリ | 69,820 KB |
実行使用メモリ | 9,412 KB |
最終ジャッジ日時 | 2024-12-14 23:47:38 |
合計ジャッジ時間 | 22,011 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 53 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main() | ^~~~
ソースコード
#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; }