結果

問題 No.1233 割り切れない気持ち
ユーザー Ricky_ponRicky_pon
提出日時 2020-09-18 23:00:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 3,153 ms
コード長 1,613 bytes
コンパイル時間 1,948 ms
コンパイル使用メモリ 198,696 KB
実行使用メモリ 8,348 KB
最終ジャッジ日時 2023-09-04 21:53:01
合計ジャッジ時間 4,760 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
7,640 KB
testcase_01 AC 5 ms
7,564 KB
testcase_02 AC 8 ms
7,564 KB
testcase_03 AC 10 ms
7,752 KB
testcase_04 AC 9 ms
7,628 KB
testcase_05 AC 8 ms
7,636 KB
testcase_06 AC 8 ms
7,768 KB
testcase_07 AC 18 ms
7,596 KB
testcase_08 AC 23 ms
7,588 KB
testcase_09 AC 35 ms
7,900 KB
testcase_10 AC 37 ms
7,988 KB
testcase_11 AC 16 ms
7,580 KB
testcase_12 AC 40 ms
8,228 KB
testcase_13 AC 40 ms
8,176 KB
testcase_14 AC 41 ms
8,164 KB
testcase_15 AC 43 ms
8,348 KB
testcase_16 AC 42 ms
8,228 KB
testcase_17 AC 20 ms
7,640 KB
testcase_18 AC 36 ms
8,224 KB
testcase_19 AC 27 ms
7,600 KB
testcase_20 AC 20 ms
7,640 KB
testcase_21 AC 23 ms
7,592 KB
testcase_22 AC 22 ms
7,560 KB
testcase_23 AC 22 ms
7,612 KB
testcase_24 AC 22 ms
7,612 KB
testcase_25 AC 22 ms
7,864 KB
testcase_26 AC 23 ms
7,632 KB
testcase_27 AC 24 ms
8,164 KB
testcase_28 AC 24 ms
7,916 KB
testcase_29 AC 24 ms
7,880 KB
testcase_30 AC 24 ms
7,860 KB
testcase_31 AC 24 ms
7,808 KB
testcase_32 AC 24 ms
7,764 KB
testcase_33 AC 24 ms
7,876 KB
testcase_34 AC 23 ms
7,792 KB
testcase_35 AC 24 ms
7,752 KB
testcase_36 AC 24 ms
7,840 KB
testcase_37 AC 6 ms
7,704 KB
testcase_38 AC 20 ms
7,664 KB
testcase_39 AC 28 ms
8,304 KB
testcase_40 AC 28 ms
8,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

lint cnt[MAX], cnt_sum[MAX], sum[MAX];

int main() {
    int n;
    scanf("%d", &n);
    rep(i, n) {
        int a;
        scanf("%d", &a);
        ++cnt[a];
        ++cnt_sum[a + 1];
        sum[a + 1] += a;
    }
    partial_sum(cnt_sum, cnt_sum + MAX, cnt_sum);
    partial_sum(sum, sum + MAX, sum);

    lint ans = 0;
    rep(i, MAX) if (cnt[i]) {
        for (int k = 0; k * i <= 200000; ++k) {
            int l = k * i, r = min(MAX - 1, (k + 1) * i);
            ans += ((sum[r] - sum[l]) - (cnt_sum[r] - cnt_sum[l]) * i * k) *
                   cnt[i];
        }
    }
    printf("%lld\n", ans);
}
0