結果
問題 |
No.929 よくあるボールを移動するやつ
|
ユーザー |
![]() |
提出日時 | 2020-01-11 13:20:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 355 bytes |
コンパイル時間 | 2,394 ms |
コンパイル使用メモリ | 193,812 KB |
最終ジャッジ日時 | 2025-01-08 17:06:41 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<int> b(n); for (int i = 0; i < n; i++) { cin >> b.at(i); } ll ans = 0; int sum = 0; for (int i = 0; i < n; i++) { sum += b.at(i); ans += (ll)abs(i + 1 - sum); } cout << ans << endl; }