結果

問題 No.1233 割り切れない気持ち
ユーザー vjudge1vjudge1
提出日時 2024-05-02 12:19:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 879 bytes
コンパイル時間 2,694 ms
コンパイル使用メモリ 199,944 KB
実行使用メモリ 14,728 KB
最終ジャッジ日時 2024-05-02 12:19:41
合計ジャッジ時間 25,385 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,056 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 3 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 527 ms
5,376 KB
testcase_08 AC 1,172 ms
5,504 KB
testcase_09 AC 2,965 ms
7,168 KB
testcase_10 TLE -
testcase_11 AC 452 ms
5,376 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 AC 41 ms
7,912 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, p[N], sum[N];

char u;

void Solve() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		maxi = max(maxi, a[i]);
		p[a[i]]++;
		sum[a[i]] += a[i];
	}
	for (int i = 1; i <= maxi + 1; i++) {
		p[i] += p[i - 1];
		sum[i] += sum[i - 1];
	}
	for (int i = 1; i <= n; i++) {
		ans += a[i] * n;
		long long tmp = 0;
	//	cout << "Case :" << i << "\n";
		for (long long 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]); 
		//	cout << l << " " << r << " " << (p[r] - p[l - 1]) << " " << (a[i] / l) * r << "\n";
		}
		ans -= tmp;
	}
	cout << ans;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
//	cin >> t;
//	while (t--) {
		Solve();
//	}
	return 0;
}
0