結果

問題 No.1262 グラフを作ろう!
ユーザー yuto1115yuto1115
提出日時 2020-10-16 23:32:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,194 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 202,688 KB
実行使用メモリ 19,028 KB
最終ジャッジ日時 2023-09-28 05:42:50
合計ジャッジ時間 19,097 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
11,852 KB
testcase_01 AC 86 ms
9,640 KB
testcase_02 AC 138 ms
13,960 KB
testcase_03 AC 104 ms
9,152 KB
testcase_04 AC 81 ms
12,616 KB
testcase_05 AC 87 ms
11,192 KB
testcase_06 AC 96 ms
14,236 KB
testcase_07 AC 21 ms
5,332 KB
testcase_08 AC 130 ms
14,900 KB
testcase_09 AC 68 ms
7,120 KB
testcase_10 AC 67 ms
8,644 KB
testcase_11 AC 142 ms
16,012 KB
testcase_12 AC 111 ms
10,828 KB
testcase_13 AC 107 ms
9,524 KB
testcase_14 AC 66 ms
9,220 KB
testcase_15 AC 54 ms
6,252 KB
testcase_16 AC 124 ms
14,284 KB
testcase_17 AC 104 ms
12,224 KB
testcase_18 AC 146 ms
15,412 KB
testcase_19 AC 66 ms
11,612 KB
testcase_20 AC 120 ms
15,656 KB
testcase_21 AC 145 ms
14,152 KB
testcase_22 AC 60 ms
10,832 KB
testcase_23 AC 72 ms
7,796 KB
testcase_24 AC 128 ms
14,680 KB
testcase_25 AC 38 ms
7,936 KB
testcase_26 AC 52 ms
9,112 KB
testcase_27 AC 100 ms
13,432 KB
testcase_28 AC 80 ms
11,796 KB
testcase_29 AC 84 ms
12,596 KB
testcase_30 AC 61 ms
9,224 KB
testcase_31 AC 128 ms
12,380 KB
testcase_32 AC 88 ms
10,548 KB
testcase_33 AC 33 ms
5,412 KB
testcase_34 AC 129 ms
15,684 KB
testcase_35 AC 103 ms
9,948 KB
testcase_36 AC 36 ms
5,156 KB
testcase_37 AC 155 ms
15,436 KB
testcase_38 AC 100 ms
12,672 KB
testcase_39 AC 66 ms
7,264 KB
testcase_40 AC 68 ms
8,608 KB
testcase_41 AC 98 ms
13,624 KB
testcase_42 AC 139 ms
15,504 KB
testcase_43 AC 84 ms
11,416 KB
testcase_44 AC 83 ms
10,808 KB
testcase_45 AC 146 ms
15,992 KB
testcase_46 AC 111 ms
15,136 KB
testcase_47 AC 71 ms
6,940 KB
testcase_48 AC 127 ms
14,132 KB
testcase_49 AC 153 ms
14,940 KB
testcase_50 AC 144 ms
15,156 KB
testcase_51 AC 82 ms
8,316 KB
testcase_52 AC 115 ms
14,480 KB
testcase_53 AC 35 ms
6,740 KB
testcase_54 AC 117 ms
11,100 KB
testcase_55 AC 94 ms
10,552 KB
testcase_56 AC 89 ms
13,068 KB
testcase_57 AC 181 ms
17,356 KB
testcase_58 AC 103 ms
10,104 KB
testcase_59 AC 95 ms
13,828 KB
testcase_60 AC 164 ms
16,368 KB
testcase_61 AC 62 ms
8,628 KB
testcase_62 AC 132 ms
13,860 KB
testcase_63 AC 114 ms
10,632 KB
testcase_64 AC 87 ms
10,328 KB
testcase_65 AC 51 ms
9,136 KB
testcase_66 AC 67 ms
9,084 KB
testcase_67 AC 66 ms
10,396 KB
testcase_68 AC 104 ms
14,932 KB
testcase_69 AC 65 ms
9,872 KB
testcase_70 AC 142 ms
16,232 KB
testcase_71 AC 109 ms
13,128 KB
testcase_72 AC 155 ms
16,520 KB
testcase_73 AC 147 ms
14,912 KB
testcase_74 AC 123 ms
12,720 KB
testcase_75 AC 122 ms
13,964 KB
testcase_76 AC 106 ms
12,940 KB
testcase_77 AC 121 ms
13,160 KB
testcase_78 AC 126 ms
14,224 KB
testcase_79 AC 158 ms
16,948 KB
testcase_80 AC 141 ms
16,560 KB
testcase_81 AC 123 ms
12,996 KB
testcase_82 AC 141 ms
14,260 KB
testcase_83 AC 137 ms
15,768 KB
testcase_84 AC 108 ms
13,228 KB
testcase_85 AC 181 ms
17,292 KB
testcase_86 AC 124 ms
13,912 KB
testcase_87 AC 147 ms
16,016 KB
testcase_88 AC 118 ms
12,780 KB
testcase_89 AC 129 ms
15,244 KB
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
testcase_94 WA -
testcase_95 AC 201 ms
18,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vi a(m);
    cin >> a;
    ll ans = 0;
    ans -= accumulate(all(a), 0LL);
    int mx = *max_element(all(a));
    vl v(mx + 1);
    vi cnt(mx + 1);
    rep(i, m) cnt[a[i]]++;
    for (int i = mx; i > 0; i--) {
        for (int j = i; j <= mx; j += i) {
            v[i] += cnt[j] * (j / i);
        }
        for (int j = i * 2; j <= mx; j += i) {
            v[i] -= v[j];
        }
        ans += v[i] * i;
    }
    cout << ans << endl;
}
0