結果

問題 No.884 Eat and Add
ユーザー suika_psuika_p
提出日時 2019-09-13 22:40:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,034 bytes
コンパイル時間 1,500 ms
コンパイル使用メモリ 166,024 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 14:52:18
合計ジャッジ時間 2,196 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    int cnt = 0;
    vector<int> a;
    rep(i, n) {
        if (s[i] == '1') {
            cnt++;
        } else if (cnt) {
            a.pb(cnt);
            cnt = 0;
        }
    }
    if (cnt) a.pb(cnt);
    int ans = 0;
    // rep(i, a.size()) cout << a[i] << ' ';
    // cout << endl;
    rep(i, a.size()) {
        if (a[i] > 2) {
            ans += 2;
        } else {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}
0