結果

問題 No.33 アメーバがたくさん
ユーザー OKCH3COOHOKCH3COOH
提出日時 2019-10-25 22:02:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,849 bytes
コンパイル時間 1,178 ms
コンパイル使用メモリ 121,680 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-11 04:18:36
合計ジャッジ時間 2,424 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using Int = unsigned int;
using llong = long long;
using Llong = unsigned long long;
using ldouble = long double;
using intV = vector<int>;
using llongV = vector<long long>;
using llongVV = vector<vector<long long>>;
using Graph = vector<vector<long long>>;
using costGraph = vector<vector<pair<long long, long long>>>;

struct Edge {
    long long from;
    long long to;
    long long cost;
};

template<typename T>
using asc = less<T>();
template<typename T>
using desc = greater<T>();

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)
#define sup(vec, a) upper_bound(vec.begin(), vec.end(), a) - vec.begin()
#define inf(vec, a) lower_bound(vec.begin(), vec.end(), a) - vec.begin()

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong N, D, T;
    cin >> N >> D >> T;

    llongVV amebaGrp(D);
    FOR(i, N) {
        llong x;
        cin >> x;
        llong mod = x % D;
        if(mod < 0) mod += D;
        amebaGrp[mod].push_back(x);
    }

    llong ans = N;
    for(llongV grp : amebaGrp) {
        if(grp.size() == 0) continue;

        ans += 2 * T;
        sort(grp.begin(), grp.end());
        FORS(i, 1, grp.size()) {
            ans += min(2 * T, (grp[i] - grp[i - 1]) / D - 1);
        }
    }

    cout << ans << endl;

    return 0;
}
0