結果
| 問題 |
No.1233 割り切れない気持ち
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-16 00:01:15 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 452 ms / 3,153 ms |
| コード長 | 924 bytes |
| コンパイル時間 | 3,860 ms |
| コンパイル使用メモリ | 251,852 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-16 00:01:26 |
| 合計ジャッジ時間 | 10,378 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 39 |
ソースコード
#ifndef LOCAL
#include <bits/stdc++.h>
using namespace std;
#define debug(...) (void(0))
#else
#include "algo/debug.h"
#endif
void solve() {
int N;
cin >> N;
vector<int> A(N);
for (auto& x : A) cin >> x;
sort(A.begin(), A.end());
uint64_t ans = 0;
for (int i = 0; i < N; i++) ans += (int64_t)N * A[i];
constexpr int M = 2e5 + 100;
vector<int> S(M);
for (const auto& x : A) S[x]++;
for (int j = 1; j <= M; j++)
if (S[j]) {
for (int i = j; i < M; i += j) {
int k = distance(lower_bound(A.begin(), A.end(), i), lower_bound(A.begin(), A.end(), i + j));
int64_t val = i / j;
ans -= val * j * k * S[j];
}
}
cout << ans << endl;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int tt = 1;
// std::cin >> tt;
while (tt--) {
solve();
}
}