結果

問題 No.2111 Sum of Diff
ユーザー 7iz67iz6
提出日時 2022-11-02 16:45:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 1,491 ms
コンパイル使用メモリ 163,800 KB
実行使用メモリ 8,092 KB
最終ジャッジ日時 2023-09-24 05:42:21
合計ジャッジ時間 4,082 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 82 ms
8,056 KB
testcase_03 AC 56 ms
6,524 KB
testcase_04 AC 12 ms
4,376 KB
testcase_05 AC 81 ms
8,092 KB
testcase_06 AC 83 ms
8,076 KB
testcase_07 AC 21 ms
4,500 KB
testcase_08 AC 28 ms
4,940 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 8 ms
4,376 KB
testcase_11 AC 40 ms
5,580 KB
testcase_12 AC 38 ms
5,524 KB
testcase_13 AC 26 ms
4,876 KB
testcase_14 AC 68 ms
7,192 KB
testcase_15 AC 78 ms
7,900 KB
testcase_16 AC 34 ms
5,540 KB
testcase_17 AC 82 ms
8,020 KB
testcase_18 AC 26 ms
5,108 KB
testcase_19 AC 62 ms
6,860 KB
testcase_20 AC 81 ms
8,016 KB
testcase_21 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL<<60;
const int MOD = 998244353;

long long pow2[200006];
long long cum[200006] = {};

int main() {
    int n; cin >> n;
    pow2[0] = 1;
    long long ans = 0;
    long long a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++) {
        pow2[i] = pow2[i-1] * 2 % MOD;
        cum[i] = cum[i-1] + pow2[i-1];
        cum[i] %= MOD;
    }
    for(int i = 0; i < n; i++) {
        ans += cum[abs(n-1-i)] * a[i];
        ans %= MOD;
        ans -= cum[abs(i-0)] * a[i];
        ans %= MOD;
        ans += MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}
0