提出 #46050928


ソースコード 拡げる

#include <bits/stdc++.h>

void solve(std::istream& is, std::ostream& os) {
    using Num = long long int;
    Num n {0};
    is >> n;

    std::vector<Num> ns;
    for(Num i{0}; i<n; ++i) {
        Num a{0};
        is >> a;
        ns.push_back(a);
    }
    ns.push_back(-10000);

    Num total {0};
    Num prev {-1};
    Num len {0};
    for(const auto& a : ns) {
        if (a == prev) {
            ++len;
        } else {
            total += (len + 1) / 2;
            len = 0;
        }
        prev = a;
    }

    os << total << "\n";
    return;
}

int main(void) {
    solve(std::cin, std::cout);
    return 0;
}

提出情報

提出日時
問題 A - Colorful Slimes 2
ユーザ zettsut
言語 C++ 20 (gcc 12.2)
得点 200
コード長 664 Byte
結果 AC
実行時間 1 ms
メモリ 3680 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 4
AC × 13
セット名 テストケース
Sample example_0, example_1, example_2, example_3
All example_0, example_1, example_2, example_3, handmade_0, handmade_1, rand_0, rand_1, smallcolor_0, smallcolor_1, smallcolor_2, smallcolor_3, smallcolor_4
ケース名 結果 実行時間 メモリ
example_0 AC 1 ms 3608 KiB
example_1 AC 1 ms 3608 KiB
example_2 AC 1 ms 3468 KiB
example_3 AC 1 ms 3492 KiB
handmade_0 AC 1 ms 3680 KiB
handmade_1 AC 1 ms 3608 KiB
rand_0 AC 1 ms 3480 KiB
rand_1 AC 1 ms 3476 KiB
smallcolor_0 AC 1 ms 3488 KiB
smallcolor_1 AC 1 ms 3464 KiB
smallcolor_2 AC 1 ms 3480 KiB
smallcolor_3 AC 1 ms 3412 KiB
smallcolor_4 AC 1 ms 3476 KiB