結果

問題 No.1233 割り切れない気持ち
ユーザー yy
提出日時 2020-09-26 10:53:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 3,386 bytes
コンパイル時間 3,244 ms
コンパイル使用メモリ 201,264 KB
実行使用メモリ 10,976 KB
最終ジャッジ日時 2023-09-11 06:38:22
合計ジャッジ時間 10,597 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,268 KB
testcase_01 AC 5 ms
6,152 KB
testcase_02 AC 6 ms
6,212 KB
testcase_03 AC 8 ms
6,484 KB
testcase_04 AC 7 ms
6,192 KB
testcase_05 AC 7 ms
6,324 KB
testcase_06 AC 6 ms
6,472 KB
testcase_07 AC 23 ms
6,584 KB
testcase_08 AC 33 ms
6,676 KB
testcase_09 AC 58 ms
7,480 KB
testcase_10 AC 61 ms
7,520 KB
testcase_11 AC 21 ms
6,476 KB
testcase_12 AC 69 ms
7,728 KB
testcase_13 AC 69 ms
7,736 KB
testcase_14 AC 69 ms
7,792 KB
testcase_15 AC 70 ms
7,840 KB
testcase_16 AC 71 ms
8,076 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
// #define LOCAL // 提出時はコメントアウト
#define DEBUG_

typedef long long ll;
const double EPS = 1e-9;
const ll INF = ((1LL<<62)-(1LL<<31));
typedef vector<ll> vecl;
typedef pair<ll, ll> pairl;
template<typename T, typename U> using mapv = map<T,vector<U>>;

#define ALL(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define contains(S,x) find(ALL(S),x) != S.end()
ll llceil(ll a,ll b) { return (a+b-1)/b; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> vector<vector<T>> genarr(ll n, ll m, T init) { return vector<vector<T>>(n,vector<T>(m,init)); }

///// DEBUG
#define DUMPOUT cerr
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
template<typename T>istream&operator>>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<typename T,typename U>ostream&operator<<(ostream&os,pair<T,U>&pair_var){os<<"("<<pair_var.first<<", "<<pair_var.second<<")";return os;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&vec){os<<"{";for(int i=0;i<vec.size();i++){os<<vec[i]<<(i+1==vec.size()?"":", ");}
os<<"}";return os;}
template<typename T,typename U>ostream&operator<<(ostream&os,map<T,U>&map_var){os<<"{";repi(itr,map_var){os<<*itr;itr++;if(itr!=map_var.end())os<<", ";itr--;}
os<<"}";return os;}
template<typename T>ostream&operator<<(ostream&os,set<T>&set_var){os<<"{";repi(itr,set_var){os<<*itr;itr++;if(itr!=set_var.end())os<<", ";itr--;}
os<<"}";return os;}
void dump_func(){DUMPOUT<<endl;}
template<class Head,class...Tail>void dump_func(Head&&head,Tail&&...tail){DUMPOUT<<head;if(sizeof...(Tail)>0){DUMPOUT<<", ";}
dump_func(std::move(tail)...);}
#ifndef LOCAL
#undef DEBUG_
#endif
#ifdef DEBUG_
#define DEB
#define dump(...)                                                          \
DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
        << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
        << endl                                                            \
        << "    ",                                                         \
    dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

//////////

template<typename T>
class Accumulation {
    public: 
        vector<T> v;
        Accumulation(const vector<ll> &X,ll N, ll init_val=0) {
            v.assign(N+1,0);
            v[0] = init_val;
            rep(i,N) {
                v[i+1] = v[i] + X[i];
            }
        }

        T query(ll l,ll r) { // [0,r]
            return v[r+1] - v[l];
        }
};

int main() {
    #ifdef LOCAL
    ifstream in("../../Atcoder/input.txt");
    cin.rdbuf(in.rdbuf());
    #endif

    ll N;
    cin>>N;

    vecl A(N);
    
    ll sum = 0;
    vecl distribution(2e5+10,0LL);
    rep(i,N) {
        cin>>A[i];
        sum += A[i];
        
        ll b = A[i];
        while (b < 2e5+10) {
            distribution[b]+=A[i];
            b += A[i];
        }
    }

    Accumulation<ll> db_acc(distribution,2e5+20);

    ll ans = sum * N;
    dump(ans);
    rep(i,N) {
        ans -= db_acc.query(0,A[i]);
    }

    cout << ans << endl;


    return 0;
}
0