結果
| 問題 | 
                            No.33 アメーバがたくさん
                             | 
                    
| コンテスト | |
| ユーザー | 
                             xuzijian629
                         | 
                    
| 提出日時 | 2018-10-28 02:25:27 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 28 ms / 5,000 ms | 
| コード長 | 922 bytes | 
| コンパイル時間 | 1,804 ms | 
| コンパイル使用メモリ | 204,780 KB | 
| 最終ジャッジ日時 | 2025-01-06 14:56:37 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 11 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
int main() {
    unordered_map<i64, vi> as;
    i64 n, d, t;
    cin >> n >> d >> t;
    for (int i = 0; i < n; i++) {
        i64 x;
        cin >> x;
        as[((x % d) + d) % d].push_back(x);
    }
    for (auto& a: as) {
        sort(a.second.begin(), a.second.end());
    }
    i64 ans = 0;
    for (auto& a: as) {
        if (a.second.size() == 1) {
            ans += 2 * t + 1;
            continue;
        }
        i64 nax = a.second.front() + t * d;
        ans += 2 * t + 1;
        for (int i = 1; i < a.second.size(); i++) {
            i64 k = a.second[i] - t * d;
            if (k > nax) {
                ans += 2 * t + 1;
            } else {
                ans += 2 * t - (nax - k) / d;
            }
            nax = a.second[i] + t * d;
        }
    }
    cout << ans << endl;
}
            
            
            
        
            
xuzijian629