結果

問題 No.33 アメーバがたくさん
コンテスト
ユーザー hogeover30
提出日時 2015-03-02 01:52:37
言語 C++11(old_compat)
(gcc 12.4.0 + boost 1.90.0)
コンパイル:
g++-12 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -include bits/stdc++.h -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
+ 282µs
コード長 632 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,085 ms
コンパイル使用メモリ 177,496 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-28 01:18:29
合計ジャッジ時間 2,331 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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