結果

問題 No.1233 割り切れない気持ち
ユーザー kyoprounokyoprouno
提出日時 2020-09-18 23:08:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 996 bytes
コンパイル時間 4,815 ms
コンパイル使用メモリ 178,032 KB
実行使用メモリ 10,712 KB
最終ジャッジ日時 2023-09-04 19:38:31
合計ジャッジ時間 18,843 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,712 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 54 ms
4,380 KB
testcase_08 AC 92 ms
4,380 KB
testcase_09 AC 192 ms
5,672 KB
testcase_10 AC 203 ms
5,600 KB
testcase_11 AC 45 ms
4,380 KB
testcase_12 AC 246 ms
6,180 KB
testcase_13 AC 234 ms
6,240 KB
testcase_14 AC 245 ms
6,296 KB
testcase_15 AC 244 ms
6,168 KB
testcase_16 AC 256 ms
6,212 KB
testcase_17 AC 25 ms
6,224 KB
testcase_18 AC 243 ms
6,164 KB
testcase_19 AC 33 ms
6,116 KB
testcase_20 AC 26 ms
6,364 KB
testcase_21 AC 33 ms
6,208 KB
testcase_22 AC 34 ms
6,132 KB
testcase_23 AC 34 ms
6,176 KB
testcase_24 AC 33 ms
6,180 KB
testcase_25 AC 34 ms
6,180 KB
testcase_26 AC 33 ms
6,176 KB
testcase_27 AC 932 ms
6,172 KB
testcase_28 AC 833 ms
6,216 KB
testcase_29 AC 755 ms
6,128 KB
testcase_30 AC 695 ms
6,208 KB
testcase_31 AC 645 ms
6,220 KB
testcase_32 AC 601 ms
6,124 KB
testcase_33 AC 565 ms
6,168 KB
testcase_34 AC 531 ms
6,120 KB
testcase_35 AC 510 ms
6,124 KB
testcase_36 AC 476 ms
6,180 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 TLE -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0