結果

問題 No.1917 LCMST
ユーザー Trí Tâm NguyễnTrí Tâm Nguyễn
提出日時 2024-03-12 23:43:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,290 bytes
コンパイル時間 3,169 ms
コンパイル使用メモリ 172,512 KB
実行使用メモリ 28,076 KB
最終ジャッジ日時 2024-03-12 23:44:28
合計ジャッジ時間 15,768 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
21,184 KB
testcase_01 AC 70 ms
21,184 KB
testcase_02 AC 66 ms
21,184 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 64 ms
21,184 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 280 ms
28,076 KB
testcase_30 AC 277 ms
28,076 KB
testcase_31 AC 276 ms
28,076 KB
testcase_32 AC 269 ms
28,076 KB
testcase_33 AC 284 ms
28,076 KB
testcase_34 AC 202 ms
28,076 KB
testcase_35 AC 212 ms
28,076 KB
testcase_36 AC 210 ms
28,076 KB
testcase_37 AC 276 ms
28,076 KB
testcase_38 AC 279 ms
28,076 KB
testcase_39 AC 276 ms
28,076 KB
testcase_40 AC 302 ms
28,076 KB
testcase_41 AC 274 ms
28,076 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ll u[100005];
vector<ll> a[100005];
ll b[1000005];
//void dfs()
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    for(ll i = 1;i <= 100000;i++)
    {
        for(ll j = i;j <= 100000;j += i)
        {
            a[j].push_back(i);
        }
    }
    ll n;
    cin >> n;
    ll i,j;
    for(i = 1;i <= n;i++) cin >> b[i];
    sort(b + 1,b + 1 + n);
    ll ans = 0;
    for(i = 1;i <= n;i++)
    {
        ll x = b[i];
        //ll y = sqrt(x);
        if(i == 1)
        {
            for(ll tmp = 0;tmp < a[x].size();tmp++)
            {
                j = a[x][tmp];
                if(u[j] == 0) u[j] = x/j;
                //else u[j] = min(u[j], x/j);
            }
        }else
        {
            ll add = LLONG_MAX/2;
            for(ll tmp = 0;tmp < a[x].size();tmp++)
            {
                j = a[x][tmp];
                if(u[j] != 0) add = min(add, x * u[j]);
                //else u[j] = min(u[j], x/j);
            }
            for(ll tmp = 0;tmp < a[x].size();tmp++)
            {
                j = a[x][tmp];
                if(u[j] == 0) u[j] = x/j;
                //else u[j] = min(u[j], x/j);
            }
            ans += add;
        }
    }
    cout << ans;
}
0