結果

問題 No.1233 割り切れない気持ち
ユーザー fumofumofunifumofumofuni
提出日時 2020-09-19 00:15:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,626 bytes
コンパイル時間 1,458 ms
コンパイル使用メモリ 167,484 KB
実行使用メモリ 11,216 KB
最終ジャッジ日時 2023-09-04 19:51:31
合計ジャッジ時間 5,142 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
9,472 KB
testcase_01 AC 7 ms
9,388 KB
testcase_02 AC 9 ms
9,348 KB
testcase_03 AC 11 ms
9,320 KB
testcase_04 AC 11 ms
9,308 KB
testcase_05 AC 9 ms
9,396 KB
testcase_06 AC 9 ms
9,380 KB
testcase_07 AC 27 ms
9,604 KB
testcase_08 AC 39 ms
9,896 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 25 ms
9,636 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 36 ms
10,880 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 35 ms
10,952 KB
testcase_21 AC 46 ms
10,884 KB
testcase_22 AC 47 ms
11,168 KB
testcase_23 AC 47 ms
10,928 KB
testcase_24 AC 46 ms
10,940 KB
testcase_25 AC 47 ms
10,976 KB
testcase_26 AC 46 ms
10,956 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 6 ms
9,340 KB
testcase_38 AC 35 ms
10,956 KB
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

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 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=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
    vector<ll> v(200001),a(n),memo(200001,-1);
    rep(i,n){
        cin >> a[i];
        v[a[i]]++;
    }
    ll sum=0;
    vl cum(200010),cnt(200010);
    rep(i,200001)cum[i+1]+=cum[i]+i*v[i];
    rep(i,200001)cnt[i+1]+=cnt[i]+v[i];
    //rep(i,10)cout<< cum[i] <<" " << cnt[i] <<endl;
    rep(i,n){
        ll p=a[i];
        if(memo[p]!=-1){sum+=memo[p];continue;}
        memo[p]=0;
        for(ll j=0;j*p+p<200001;j++){
            memo[p]+=cum[j*p+p]-cum[j*p]-j*p*(cnt[j*p+p]-cnt[j*p]);
        }
        sum+=memo[p];
        //cout << sum<<endl;
    }
    cout << sum <<endl;
}
0