結果

問題 No.1233 割り切れない気持ち
ユーザー t33ft33f
提出日時 2020-09-18 21:40:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 584 bytes
コンパイル時間 1,920 ms
コンパイル使用メモリ 68,756 KB
実行使用メモリ 5,760 KB
最終ジャッジ日時 2023-09-04 18:49:55
合計ジャッジ時間 9,971 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,060 KB
testcase_01 AC 4 ms
4,380 KB
testcase_02 AC 14 ms
4,380 KB
testcase_03 AC 55 ms
4,380 KB
testcase_04 AC 31 ms
4,376 KB
testcase_05 AC 22 ms
4,376 KB
testcase_06 AC 20 ms
4,380 KB
testcase_07 AC 178 ms
4,376 KB
testcase_08 AC 233 ms
4,376 KB
testcase_09 AC 386 ms
5,340 KB
testcase_10 AC 397 ms
5,420 KB
testcase_11 AC 149 ms
4,376 KB
testcase_12 AC 467 ms
5,716 KB
testcase_13 AC 446 ms
5,760 KB
testcase_14 AC 465 ms
5,720 KB
testcase_15 AC 468 ms
5,756 KB
testcase_16 AC 487 ms
5,704 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n];
    long long s[n+1];
    s[0] = 0;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    for (int i = 0; i < n; i++) {
        s[i+1] = s[i] + a[i];
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        for (int m = 0; m <= 2e5; m += a[i]) {
            int l = lower_bound(a, a+n, m) - a,
                r = lower_bound(a, a+n, m+a[i]) - a;
            ans += s[r] - s[l] - (long long)m * (r - l);
        }
    }
    cout << ans << endl;
}
0