結果

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

テストケース

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

ソースコード

diff #

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

int main() {
    int N, D, T;
    const int INF = 1e9;
    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++) {
        int x;
        std::cin >> x;
        x += INF;
        X.at(i) = x;
    }

    for (const auto &x: X) {
        int mod = x % D;
        line[mod].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