結果

問題 No.1233 割り切れない気持ち
ユーザー fumofumofunifumofumofuni
提出日時 2021-09-21 15:43:12
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 76 ms / 3,153 ms
コード長 1,550 bytes
コンパイル時間 2,160 ms
コンパイル使用メモリ 200,316 KB
実行使用メモリ 9,640 KB
最終ジャッジ日時 2023-09-17 01:44:03
合計ジャッジ時間 7,270 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,772 KB
testcase_01 AC 16 ms
7,740 KB
testcase_02 AC 16 ms
8,040 KB
testcase_03 AC 16 ms
7,920 KB
testcase_04 AC 16 ms
7,788 KB
testcase_05 AC 16 ms
7,844 KB
testcase_06 AC 16 ms
7,728 KB
testcase_07 AC 30 ms
8,056 KB
testcase_08 AC 40 ms
8,360 KB
testcase_09 AC 63 ms
9,240 KB
testcase_10 AC 65 ms
9,180 KB
testcase_11 AC 28 ms
8,112 KB
testcase_12 AC 74 ms
9,320 KB
testcase_13 AC 74 ms
9,412 KB
testcase_14 AC 73 ms
9,380 KB
testcase_15 AC 74 ms
9,356 KB
testcase_16 AC 73 ms
9,436 KB
testcase_17 AC 45 ms
9,416 KB
testcase_18 AC 72 ms
9,328 KB
testcase_19 AC 76 ms
9,356 KB
testcase_20 AC 46 ms
9,416 KB
testcase_21 AC 56 ms
9,352 KB
testcase_22 AC 56 ms
9,464 KB
testcase_23 AC 56 ms
9,384 KB
testcase_24 AC 56 ms
9,328 KB
testcase_25 AC 56 ms
9,388 KB
testcase_26 AC 57 ms
9,484 KB
testcase_27 AC 64 ms
9,640 KB
testcase_28 AC 64 ms
9,436 KB
testcase_29 AC 64 ms
9,380 KB
testcase_30 AC 64 ms
9,320 KB
testcase_31 AC 65 ms
9,620 KB
testcase_32 AC 64 ms
9,428 KB
testcase_33 AC 64 ms
9,312 KB
testcase_34 AC 64 ms
9,316 KB
testcase_35 AC 64 ms
9,312 KB
testcase_36 AC 64 ms
9,380 KB
testcase_37 AC 16 ms
7,852 KB
testcase_38 AC 46 ms
9,420 KB
testcase_39 AC 59 ms
9,308 KB
testcase_40 AC 58 ms
9,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e17;
const ll dy[9]={0,1,-1,0,1,1,-1,-1,0};
const ll dx[9]={1,0,0,-1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


int main(){
    ll n;cin >> n;
    vl v(n);rep(i,n)cin >> v[i];
    vl cnt(200010);rep(i,n)cnt[v[i]]++;
    ll ans=0;
    vl cs(200010),cm(200010);
    rep(i,n)cs[v[i]]++;
    rep(i,n)cm[v[i]]+=v[i];
    rep(i,200009)cs[i+1]+=cs[i];
    rep(i,200009)cm[i+1]+=cm[i];
    for(ll i=1;i<=200000;i++){
        for(ll j=0;j<200010;j+=i){
            ll next=j+i-1;chmin(next,200009LL);
            ans+=(cm[next]-cm[j]-(cs[next]-cs[j])*j)*cnt[i];
        }
    }
    cout << ans << endl;
}      


0