結果

問題 No.1233 割り切れない気持ち
ユーザー milanis48663220milanis48663220
提出日時 2020-09-18 22:07:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 441 ms / 3,153 ms
コード長 906 bytes
コンパイル時間 785 ms
コンパイル使用メモリ 85,404 KB
実行使用メモリ 6,760 KB
最終ジャッジ日時 2023-09-04 21:48:19
合計ジャッジ時間 10,857 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
4,948 KB
testcase_01 AC 30 ms
5,180 KB
testcase_02 AC 44 ms
4,912 KB
testcase_03 AC 64 ms
4,960 KB
testcase_04 AC 64 ms
4,992 KB
testcase_05 AC 44 ms
5,028 KB
testcase_06 AC 45 ms
5,196 KB
testcase_07 AC 177 ms
5,460 KB
testcase_08 AC 238 ms
5,652 KB
testcase_09 AC 374 ms
6,240 KB
testcase_10 AC 389 ms
6,320 KB
testcase_11 AC 168 ms
5,324 KB
testcase_12 AC 439 ms
6,760 KB
testcase_13 AC 440 ms
6,520 KB
testcase_14 AC 438 ms
6,448 KB
testcase_15 AC 441 ms
6,496 KB
testcase_16 AC 441 ms
6,572 KB
testcase_17 AC 143 ms
6,508 KB
testcase_18 AC 428 ms
6,460 KB
testcase_19 AC 126 ms
6,512 KB
testcase_20 AC 142 ms
6,592 KB
testcase_21 AC 150 ms
6,524 KB
testcase_22 AC 150 ms
6,452 KB
testcase_23 AC 151 ms
6,496 KB
testcase_24 AC 150 ms
6,572 KB
testcase_25 AC 151 ms
6,548 KB
testcase_26 AC 151 ms
6,544 KB
testcase_27 AC 167 ms
6,632 KB
testcase_28 AC 165 ms
6,516 KB
testcase_29 AC 163 ms
6,632 KB
testcase_30 AC 163 ms
6,500 KB
testcase_31 AC 161 ms
6,524 KB
testcase_32 AC 161 ms
6,476 KB
testcase_33 AC 159 ms
6,468 KB
testcase_34 AC 158 ms
6,588 KB
testcase_35 AC 156 ms
6,504 KB
testcase_36 AC 155 ms
6,548 KB
testcase_37 AC 21 ms
5,004 KB
testcase_38 AC 146 ms
6,524 KB
testcase_39 AC 383 ms
6,548 KB
testcase_40 AC 383 ms
6,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int N;
ll a[200000];
ll sum[200005];


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    ll sum_all = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        sum_all += a[i];
    }
    sort(a, a+N);
    ll ans = sum_all*N;
    for(int i = 1; i <= 200000; i++){
        for(int j = 0; i*j <= 200000; j++){
            // i*j <= x < i*(j+1)をもとめたい
            auto pl = lower_bound(a, a+N, i*j);
            auto pr = lower_bound(a, a+N, i*(j+1));
            ll cnt = pr-pl;
            sum[i] += cnt*j*i;
        }
    }
    for(int i = 0; i < N; i++){
        ans -= sum[a[i]];
        // cout << sum[a[i]] << endl;
    }
    cout << ans << endl;
}
0