結果

問題 No.1546 [Cherry 2nd Tune D] 思ったよりも易しくない
ユーザー umezoumezo
提出日時 2021-06-11 22:47:20
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 823 bytes
コンパイル時間 2,569 ms
コンパイル使用メモリ 200,880 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2023-08-21 13:34:39
合計ジャッジ時間 9,373 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 40 ms
5,612 KB
testcase_14 AC 99 ms
9,308 KB
testcase_15 AC 52 ms
6,400 KB
testcase_16 AC 51 ms
6,184 KB
testcase_17 AC 38 ms
5,324 KB
testcase_18 AC 71 ms
7,800 KB
testcase_19 AC 66 ms
7,280 KB
testcase_20 AC 81 ms
8,348 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 AC 71 ms
7,428 KB
testcase_23 AC 60 ms
6,664 KB
testcase_24 AC 13 ms
4,376 KB
testcase_25 AC 104 ms
9,572 KB
testcase_26 AC 108 ms
10,096 KB
testcase_27 AC 52 ms
6,400 KB
testcase_28 AC 109 ms
10,084 KB
testcase_29 AC 107 ms
10,064 KB
testcase_30 AC 108 ms
10,180 KB
testcase_31 AC 110 ms
10,196 KB
testcase_32 AC 108 ms
10,032 KB
testcase_33 AC 109 ms
10,096 KB
testcase_34 AC 108 ms
10,072 KB
testcase_35 AC 109 ms
10,184 KB
testcase_36 AC 109 ms
10,136 KB
testcase_37 AC 107 ms
10,024 KB
testcase_38 AC 109 ms
10,176 KB
testcase_39 AC 108 ms
10,124 KB
testcase_40 AC 108 ms
10,152 KB
testcase_41 AC 108 ms
10,032 KB
testcase_42 AC 109 ms
10,068 KB
testcase_43 AC 91 ms
10,176 KB
testcase_44 AC 91 ms
10,368 KB
testcase_45 AC 90 ms
10,080 KB
testcase_46 AC 89 ms
10,080 KB
testcase_47 AC 89 ms
10,132 KB
testcase_48 AC 110 ms
10,100 KB
testcase_49 AC 108 ms
10,072 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

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

const int MOD=998244353;
const ll REV=291154603;

ll N=0;
ll f(ll x){
  ll res=1;
  res=res*x%MOD;
  res=res*(x+1)%MOD;
  res=res*(x+2)%MOD;
  res=res*((3*x%MOD-4*N%MOD-3+MOD)%MOD)%MOD;
  res=(-res+MOD)%MOD;
  res=res*REV%MOD;
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  vector<ll> T(n+1),V(n+1);
  rep(i,n) cin>>T[i+1]>>V[i+1];
  
  for(int i=1;i<=n;i++) N=(N+T[i])%MOD;
  
  vector<ll> S(n+1);
  for(int i=1;i<=n;i++) S[i]=(S[i-1]+T[i])%MOD;
  
  ll sum=0;
  for(int i=1;i<=n;i++){
    ll tmp=V[i];
    tmp=tmp*((f(S[i])-f(S[i-1])+MOD)%MOD)%MOD;
    sum=(sum+tmp)%MOD;
  }
  cout<<sum<<endl;
  
  return 0;
}
0