結果

問題 No.1233 割り切れない気持ち
ユーザー YamaKasaYamaKasa
提出日時 2020-09-19 17:14:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,292 bytes
コンパイル時間 4,109 ms
コンパイル使用メモリ 170,308 KB
実行使用メモリ 17,516 KB
最終ジャッジ日時 2023-09-05 22:46:25
合計ジャッジ時間 6,675 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,804 KB
testcase_01 AC 3 ms
4,808 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 32 ms
6,464 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 31 ms
6,440 KB
testcase_21 AC 50 ms
6,676 KB
testcase_22 AC 49 ms
6,604 KB
testcase_23 AC 50 ms
6,484 KB
testcase_24 AC 50 ms
6,384 KB
testcase_25 AC 51 ms
6,532 KB
testcase_26 AC 50 ms
6,668 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 3 ms
5,156 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAX = 200000;
ll b[MAX + 1]{};
ll c[MAX + 1]{};

int main() {
    int N;
    cin >> N;
    ll A[N];
    int MAX = 200000;
    ll sum = 0;
    set<int> s;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        b[A[i]]++;
        s.insert(A[i]);
        sum += A[i];
    }
    
    for (int i = 1; i < MAX; i++) {
        c[i] = c[i - 1] + b[i]; 
    }
    ll ans = sum * N;
    //cout << ans << "\n";
    for (int i : s) {
        int t = i;
        if (i == 1) {
            ans -= b[1] * sum;
            continue;
        }
        //cout << "***********\n";
        //cout << i << "\n";
        for (int k = 1; k < 5; k++) {
            int l = i * k - 1;
            int r = min(MAX, i * (k + 1) - 1);
            if (l > MAX) break;
            //cout << l << " " << r << "\n";
            //cout << c[r + 1] - c[l + 1] << " " << b[i * k] << "\n";
            
            ll e = (c[r] - c[l]) * k * i * b[i];
            ans -= e;
            //cout << e << "\n";
        }
    }
    cout << ans << "\n";
    // for (int i = 0; i < 10; i++) {
    //     cout << b[i] << " ";
    // }
    // cout << "\n";
    // for (int i = 0; i < 10; i++) {
    //     cout << c[i] << " ";
    // }
    return 0;
}
0