結果

問題 No.1917 LCMST
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2022-04-29 23:51:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 992 bytes
コンパイル時間 1,709 ms
コンパイル使用メモリ 173,952 KB
実行使用メモリ 7,772 KB
最終ジャッジ日時 2023-09-11 15:35:29
合計ジャッジ時間 17,152 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 4 ms
4,380 KB
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 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 345 ms
7,416 KB
testcase_30 AC 346 ms
7,220 KB
testcase_31 AC 344 ms
7,376 KB
testcase_32 AC 344 ms
7,564 KB
testcase_33 AC 344 ms
7,416 KB
testcase_34 AC 278 ms
7,404 KB
testcase_35 AC 277 ms
7,404 KB
testcase_36 AC 275 ms
7,416 KB
testcase_37 AC 342 ms
7,456 KB
testcase_38 AC 346 ms
7,336 KB
testcase_39 AC 344 ms
7,524 KB
testcase_40 AC 345 ms
7,584 KB
testcase_41 AC 344 ms
7,580 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2022.04.29 23:51:39
**/

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


int main() {
    int n;cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vector<bool> b(100001);
    vector<int> c(100001);
    b[a[0]] = true;
    ll cnt = 1;
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        if (a[i-1] != a[i]) {
            ans += (cnt-1)*a[i-1];
            b.push_back(a[i]);
            b[a[i]] = true;
            c[a[i]] = a[i];
            cnt = 1;
        }
        else {
            cnt++;
        }
    }
    ans += (cnt-1)*a[n-1];
    for (int i = 1; i <= 100000; i++) {
        int k = 0;
        if (b[i]) k = 1;
        ans += (ll)i*c[i];
        for (int j = i; j <= 100000; j+=i) {
            if (k == 0 && b[j]) k = j/i;
            else if (k > 0) c[j] = min(c[j],k);
        }
    }
    cout << ans << endl;
}
0