結果

問題 No.33 アメーバがたくさん
コンテスト
ユーザー hogeover30
提出日時 2015-03-02 01:52:37
言語 C++11(old_compat)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -include bits/stdc++.h -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 632 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,439 ms
コンパイル使用メモリ 180,064 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-08 16:01:47
合計ジャッジ時間 2,016 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
int main()
{
    int n, d, t;
    while (cin>>n>>d>>t) {
        vector<int> x(n);
        for(int& v: x) cin>>v;
        sort(begin(x), end(x));
        for(int i=1;i<n;++i) x[i]-=x[0];
        x[0]=0;

        unordered_map<int, vector<int>> a;
        for(int v: x) a[v%d].push_back(v/d);
        
        long long res=0;
        for(auto& v: a) {
            auto& w=v.second;
            res+=2*t+1;
            for(int i=1;i<w.size();++i)
                res+=2*t+1-max(0, w[i-1]+t+1-(w[i]-t));
        }
        cout<<res<<endl;
    }
}
0