結果

問題 No.33 アメーバがたくさん
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-05-21 11:33:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,035 bytes
コンパイル時間 1,804 ms
コンパイル使用メモリ 180,524 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 20:17:55
合計ジャッジ時間 2,377 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;

int N, D, T;

int calc(vector<int> x) {
    sort(all(x));
    int cnt = (2 * T + 1) * x.size();
    int r = x[0] + D * T;
    rep2(i, 1, x.size()) {
        int l = x[i] - D * T;
        if (l <= r) {
            cnt -= (r - l) / D + 1;
        }
        r = x[i] + D * T;
    }
    return cnt;
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    cin >> N >> D >> T;
    map<int, vector<int>> group;    // {mod, value}
    rep(i, N) {
        int x;
        cin >> x;
        group[(x + (int)1e10) % D].emplace_back(x);
    }

    int ans = 0;
    for (auto p : group) {
        ans += calc(p.second);
    }
    cout << ans << endl;
}
0