結果

問題 No.1233 割り切れない気持ち
ユーザー vjudge1vjudge1
提出日時 2024-05-02 12:39:00
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 607 bytes
コンパイル時間 1,474 ms
コンパイル使用メモリ 157,020 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-05-02 12:39:42
合計ジャッジ時間 36,355 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
11,520 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 550 ms
5,376 KB
testcase_08 AC 1,058 ms
5,376 KB
testcase_09 AC 2,719 ms
5,888 KB
testcase_10 AC 2,946 ms
6,144 KB
testcase_11 AC 405 ms
5,376 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 AC 42 ms
5,376 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std; 

const int N = 2e5 + 5;

int t, n;

long long a[N], ans, maxi, sum[N], tmp;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.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 (long long l = 1, r = 0; l <= a[i]; l = r + 1) {
			r = a[i] / (a[i] / l);
			tmp += (a[i] / l) * (sum[r] - sum[l - 1]);
		}
		ans -= tmp;
	}
	cout << ans;
	return 0;
}
0