結果
| 問題 |
No.1917 LCMST
|
| コンテスト | |
| ユーザー |
🍮かんプリン
|
| 提出日時 | 2022-04-29 23:51:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 992 bytes |
| コンパイル時間 | 1,769 ms |
| コンパイル使用メモリ | 177,188 KB |
| 実行使用メモリ | 7,708 KB |
| 最終ジャッジ日時 | 2024-06-29 05:42:04 |
| 合計ジャッジ時間 | 17,723 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 28 |
ソースコード
/**
* @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;
}
🍮かんプリン