結果
問題 | No.1233 割り切れない気持ち |
ユーザー |
![]() |
提出日時 | 2020-09-18 22:07:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 402 ms / 3,153 ms |
コード長 | 906 bytes |
コンパイル時間 | 891 ms |
コンパイル使用メモリ | 85,796 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-22 19:16:22 |
合計ジャッジ時間 | 9,363 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 39 |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <set> #include <map> using namespace std; typedef long long ll; int N; ll a[200000]; ll sum[200005]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; cin >> N; ll sum_all = 0; for(int i = 0; i < N; i++) { cin >> a[i]; sum_all += a[i]; } sort(a, a+N); ll ans = sum_all*N; for(int i = 1; i <= 200000; i++){ for(int j = 0; i*j <= 200000; j++){ // i*j <= x < i*(j+1)をもとめたい auto pl = lower_bound(a, a+N, i*j); auto pr = lower_bound(a, a+N, i*(j+1)); ll cnt = pr-pl; sum[i] += cnt*j*i; } } for(int i = 0; i < N; i++){ ans -= sum[a[i]]; // cout << sum[a[i]] << endl; } cout << ans << endl; }