結果

問題 No.929 よくあるボールを移動するやつ
ユーザー YamaKasa
提出日時 2019-11-30 00:47:13
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 337 bytes
コンパイル時間 1,596 ms
コンパイル使用メモリ 165,852 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-21 00:24:00
合計ジャッジ時間 2,362 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int B[N];
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    ll ans = 0;
    ll t = 0;
    for (int i = 0; i < N; i++) {
        t += B[i] - 1;
        ans += abs(t);
    }
    cout << ans << "\n";
    return 0;
}
0