結果
問題 | No.929 よくあるボールを移動するやつ |
ユーザー |
|
提出日時 | 2020-01-28 16:56:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 371 bytes |
コンパイル時間 | 2,015 ms |
コンパイル使用メモリ | 194,100 KB |
最終ジャッジ日時 | 2025-01-08 20:41:43 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {ios::sync_with_stdio(false);int N;cin >> N;vector<int> A(N);for (int i = 0; i < N; ++i) cin >> A[i];vector<int> pa(N + 1);for (int i = 0; i < N; ++i) pa[i + 1] = pa[i] + A[i];int64_t ans = 0;for (int i = 1; i < N; ++i) ans += abs(pa[i] - i);cout << ans << endl;return 0;}