結果

問題 No.929 よくあるボールを移動するやつ
ユーザー tktk_snsn
提出日時 2021-03-17 22:47:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 424 bytes
コンパイル時間 1,702 ms
コンパイル使用メモリ 170,928 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-15 17:30:48
合計ジャッジ時間 2,808 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 1 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> emp, fil, b(n);
    for (int i=0; i<n; ++i) {
        cin >> b[i];
        if (b[i]) fil.push_back(i);
        else emp.push_back(i);
    }
    int i = 0, j = 0;
    int ans = 0;
    while (i < emp.size()) {
        while (b[fil[j]]<=1) j++;
        ans += abs(emp[i]-fil[j]);
        i++;
    }
    cout << ans << endl;
}
0