結果
問題 | No.1233 割り切れない気持ち |
ユーザー |
![]() |
提出日時 | 2020-09-18 23:08:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 996 bytes |
コンパイル時間 | 1,927 ms |
コンパイル使用メモリ | 181,704 KB |
実行使用メモリ | 13,340 KB |
最終ジャッジ日時 | 2024-06-22 17:19:05 |
合計ジャッジ時間 | 16,249 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 TLE * 1 -- * 2 |
ソースコード
#pragma GCC optimize("O3")#include <bits/stdc++.h>#define ll long long#define rep(i,n) for(ll i=0;i<(n);i++)#define pll pair<ll,ll>#define pii pair<int,int>#define pq priority_queue#define pb push_back#define eb emplace_back#define fi first#define se second#define endl '\n'#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))using namespace std;int main(){ios;ll n;cin >> n;vector<ll> a(n);rep(i,n){cin >> a[i];}sort(a.begin(),a.end());ll ans=0;vector<ll> s(n+1);for(ll i=n;i>=1;i--){s[i-1]=s[i]+a[i-1];}rep(i,n){ans+=(n-1-i)*a[i]+s[i+1];}rep(i,n){for(ll j=1;j<=a[n-1]/a[i];j++){auto it=lower_bound(a.begin(),a.end(),j*a[i])-a.begin();ans-=a[i]*(n-it);}}cout << ans+s[0] << endl;return 0;}