結果

問題 No.1233 割り切れない気持ち
ユーザー vjudge1vjudge1
提出日時 2024-05-02 12:22:31
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 628 bytes
コンパイル時間 2,256 ms
コンパイル使用メモリ 199,800 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-23 02:05:23
合計ジャッジ時間 34,795 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 29 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std; 

const int N = 2e5 + 5;

int t, n, a[N], ans, maxi, sum[N], tmp;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		maxi = max(maxi, a[i]);
		sum[a[i]] += a[i];
		ans += a[i];
	}
	for (int i = 1; i <= maxi + 1; i++) {
		sum[i] += sum[i - 1];
	}
	ans *= n;
	for (int i = 1; i <= n; i++) {
		tmp = 0;
		for (int l = 1, r = 0; l <= maxi && r <= maxi; l = r + 1) {
			if (!(a[i] / l)) {
				break;
			}
			r = a[i] / (a[i] / l);
			tmp += (a[i] / l) * (sum[r] - sum[l - 1]);
		}
		ans -= tmp;
	}
	cout << ans;
	return 0;
}
0