結果
問題 |
No.1233 割り切れない気持ち
|
ユーザー |
![]() |
提出日時 | 2025-08-15 15:15:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 672 bytes |
コンパイル時間 | 2,044 ms |
コンパイル使用メモリ | 197,688 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-08-15 15:15:40 |
合計ジャッジ時間 | 11,123 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 TLE * 1 -- * 31 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAXN = 2e5 + 10, INF = 2e9; ll n, a[MAXN], s[MAXN]; int main() { cin.tie(0)->sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++) { s[i] = s[i - 1] + a[i]; } ll ans = 0; for (int i = 1; i <= n; i++) { ll sum = a[i] * n; for (int l = 1, r; l <= n; l = r + 1) { int val = a[i] / a[l] == 0 ? INF : a[i] / (a[i] / a[l]); r = upper_bound(a + 1, a + n + 1, val) - a - 1; sum -= (s[r] - s[l - 1]) * (a[i] / a[l]); } ans += sum; } cout << ans; return 0; }