結果

問題 No.1233 割り切れない気持ち
ユーザー t33f
提出日時 2020-09-18 21:40:00
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 584 bytes
コンパイル時間 840 ms
コンパイル使用メモリ 70,300 KB
実行使用メモリ 12,572 KB
最終ジャッジ日時 2024-06-22 16:36:07
合計ジャッジ時間 10,220 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15 TLE * 1 -- * 23
権限があれば一括ダウンロードができます

ソースコード

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