結果

問題 No.33 アメーバがたくさん
ユーザー H3PO4H3PO4
提出日時 2023-02-22 15:10:52
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 1,070 ms
コンパイル使用メモリ 97,820 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 23:04:36
合計ジャッジ時間 1,608 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <vector>

int main() {
    int N, D, T;
    std::cin >> N >> D >> T;
    std::unordered_map<int, std::vector<int>> line;
    std::vector<int> X(N);
    for (int i = 0; i < N; i++) { std::cin >> X.at(i); }

    for (const auto &x: X) {
        line[x % D].push_back(x / D);
    }
    int ans = 0;
    for (auto &[k, v]: line) {
        std::sort(v.begin(), v.end());
        ans += 2 * T + 1;
        for (int i = 0; i < v.size() - 1; i++) {
            ans += v.at(i + 1) + T - std::max({v.at(i + 1) - T - 1, v.at(i) + T});
        }
    }
    std::cout << ans << std::endl;
}
0