結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
9,456 KB
testcase_01 AC 7 ms
9,316 KB
testcase_02 AC 9 ms
9,372 KB
testcase_03 AC 12 ms
9,364 KB
testcase_04 AC 10 ms
9,396 KB
testcase_05 AC 10 ms
9,396 KB
testcase_06 AC 10 ms
9,324 KB
testcase_07 AC 28 ms
9,584 KB
testcase_08 AC 39 ms
9,984 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 26 ms
9,588 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 35 ms
10,956 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 35 ms
10,960 KB
testcase_21 AC 47 ms
10,904 KB
testcase_22 AC 47 ms
11,052 KB
testcase_23 AC 48 ms
10,888 KB
testcase_24 AC 47 ms
10,956 KB
testcase_25 AC 47 ms
10,912 KB
testcase_26 AC 47 ms
11,052 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 7 ms
9,304 KB
testcase_38 AC 36 ms
10,948 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(200002),cnt(200002);
    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<200002;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