結果

問題 No.33 アメーバがたくさん
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2022-12-19 22:55:19
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 755 bytes
コンパイル時間 1,390 ms
コンパイル使用メモリ 147,560 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 02:33:38
合計ジャッジ時間 1,879 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>

using namespace std;

int main(){

    long long N, D, T, X, ans=0;
    cin >> N >> D >> T;
    map<long long, vector<long long>> mp;
    for (int i=0; i<N; i++){
        cin >> X;
        mp[(X%D+D)%D].push_back(X);
    }

    for (auto &[x, y] : mp) sort(y.begin(), y.end());

    for (auto [x, y] : mp){
        ans += T * 2 + y.size();
        if (y.size() == 1) continue;
        for (int i=0; i<y.size()-1; i++){
            long long Z = (y[i+1]-y[i])/D-1;
            ans += min(Z, T * 2);
        }
    }

    cout << ans << endl;

    return 0;
}
0