結果

問題 No.1096 Range Sums
ユーザー わなわなわなわな
提出日時 2020-06-26 22:39:43
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 633 bytes
コンパイル時間 1,398 ms
コンパイル使用メモリ 166,040 KB
実行使用メモリ 6,204 KB
最終ジャッジ日時 2023-09-18 06:15:13
合計ジャッジ時間 2,324 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 37 ms
6,176 KB
testcase_11 AC 37 ms
6,120 KB
testcase_12 AC 37 ms
6,204 KB
testcase_13 AC 38 ms
6,120 KB
testcase_14 AC 37 ms
6,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
long long repow(long long x, long long y){
    if(y == 0) return 1;
    long long res = 1;
    while(y > 0){
        if(y & 1) res *= x;
        x *= x;
        y >>= 1;
    }
    return res;
}
int main(){
    int N;
    cin >> N;
    vector<long long> t(N);
    long long res = N;
    long long cnt = 1;
    for(int i = 0; i < N; i++){
        t[i] = res * cnt;
        res--;
        cnt++;
    }
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    long long ans = 0;
    for(int i = 0; i < N; i++){
        ans += A[i] * t[i];
    }
    cout << ans << endl;
} 
0