結果

問題 No.33 アメーバがたくさん
ユーザー h_nosonh_noson
提出日時 2016-03-25 13:36:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 778 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 77,956 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 20:16:20
合計ジャッジ時間 1,267 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000

typedef long long ll;

int main() {
    int i, j, n, d;
    ll t,ans;
    map<int,vector<int>> m;
    cin >> n >> d >> t;
    ans = 0;
    rep (i,n) {
        int x;
        cin >> x;
        int y = (x%d+d)%d;
        m[y].push_back((x-y)/d);
    }
    for (auto p : m) {
        auto v = p.second;
        sort(v.begin(),v.end());
        ll left = -2e9-1;
        for (ll x : v) {
            ans += min(2*t + 1,x + t - left);
            left = x + t;
        }
    }
    cout << ans << endl;
    return 0;
}
0