結果
| 問題 |
No.1233 割り切れない気持ち
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2024-05-02 11:01:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 764 bytes |
| コンパイル時間 | 1,938 ms |
| コンパイル使用メモリ | 166,104 KB |
| 実行使用メモリ | 18,560 KB |
| 最終ジャッジ日時 | 2024-11-23 00:16:05 |
| 合計ジャッジ時間 | 178,537 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 2 |
| other | TLE * 39 |
ソースコード
#include <bits/stdc++.h>
#define int long long
using namespace std;
int cnt[200020], ci[200020], n, arr[200020];
void add(int x, int v) {
int tmp = x * v;
for(; x <= 200000; x += x & -x) {
ci[x] += tmp;
}
}
int queryi(int l) {
int ans = 0;
for(; l; l -= l & -l) {
ans += ci[l];
}
return ans;
}
int cal(int l, int r, int c) {
return c * (queryi(r) - queryi(l - 1));
}
signed main() {
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> arr[i];
cnt[arr[i]]++;
}
long long ans = 0;
for(int i = 1; i <= 200000; i++) {
ans += n * cnt[i] * i;
add(i, cnt[i]);
for(int j = 1; j <= i; ) {
int r = i / (i / j);
ans -= cnt[i] * cal(j, r, i / j);
j = r + 1;
}
}
cout << ans << '\n';
return 0;
}
vjudge1