結果
問題 | No.1262 グラフを作ろう! |
ユーザー | yuto1115 |
提出日時 | 2020-10-16 23:32:26 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,194 bytes |
コンパイル時間 | 1,913 ms |
コンパイル使用メモリ | 204,424 KB |
実行使用メモリ | 18,944 KB |
最終ジャッジ日時 | 2024-07-21 00:10:58 |
合計ジャッジ時間 | 18,138 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 111 ms
12,032 KB |
testcase_01 | AC | 99 ms
9,984 KB |
testcase_02 | AC | 134 ms
14,208 KB |
testcase_03 | AC | 99 ms
9,344 KB |
testcase_04 | AC | 83 ms
12,800 KB |
testcase_05 | AC | 83 ms
11,264 KB |
testcase_06 | AC | 101 ms
14,464 KB |
testcase_07 | AC | 20 ms
5,376 KB |
testcase_08 | AC | 132 ms
15,104 KB |
testcase_09 | AC | 68 ms
7,296 KB |
testcase_10 | AC | 66 ms
8,832 KB |
testcase_11 | AC | 143 ms
16,256 KB |
testcase_12 | AC | 108 ms
11,136 KB |
testcase_13 | AC | 104 ms
9,856 KB |
testcase_14 | AC | 67 ms
9,088 KB |
testcase_15 | AC | 58 ms
6,400 KB |
testcase_16 | AC | 134 ms
14,464 KB |
testcase_17 | AC | 104 ms
12,544 KB |
testcase_18 | AC | 152 ms
15,488 KB |
testcase_19 | AC | 71 ms
11,648 KB |
testcase_20 | AC | 130 ms
15,744 KB |
testcase_21 | AC | 166 ms
14,336 KB |
testcase_22 | AC | 64 ms
11,008 KB |
testcase_23 | AC | 78 ms
7,936 KB |
testcase_24 | AC | 133 ms
15,104 KB |
testcase_25 | AC | 38 ms
8,320 KB |
testcase_26 | AC | 57 ms
9,472 KB |
testcase_27 | AC | 103 ms
13,696 KB |
testcase_28 | AC | 84 ms
12,160 KB |
testcase_29 | AC | 83 ms
12,800 KB |
testcase_30 | AC | 58 ms
9,600 KB |
testcase_31 | AC | 119 ms
12,288 KB |
testcase_32 | AC | 83 ms
10,880 KB |
testcase_33 | AC | 32 ms
5,504 KB |
testcase_34 | AC | 127 ms
16,000 KB |
testcase_35 | AC | 98 ms
9,984 KB |
testcase_36 | AC | 33 ms
5,376 KB |
testcase_37 | AC | 150 ms
15,744 KB |
testcase_38 | AC | 98 ms
12,928 KB |
testcase_39 | AC | 62 ms
7,552 KB |
testcase_40 | AC | 63 ms
8,576 KB |
testcase_41 | AC | 94 ms
13,696 KB |
testcase_42 | AC | 142 ms
15,488 KB |
testcase_43 | AC | 85 ms
11,392 KB |
testcase_44 | AC | 81 ms
11,008 KB |
testcase_45 | AC | 140 ms
16,256 KB |
testcase_46 | AC | 105 ms
15,360 KB |
testcase_47 | AC | 70 ms
7,168 KB |
testcase_48 | AC | 126 ms
14,464 KB |
testcase_49 | AC | 146 ms
15,104 KB |
testcase_50 | AC | 139 ms
15,616 KB |
testcase_51 | AC | 81 ms
8,448 KB |
testcase_52 | AC | 108 ms
14,720 KB |
testcase_53 | AC | 32 ms
6,912 KB |
testcase_54 | AC | 110 ms
11,392 KB |
testcase_55 | AC | 89 ms
10,752 KB |
testcase_56 | AC | 98 ms
13,312 KB |
testcase_57 | AC | 170 ms
17,536 KB |
testcase_58 | AC | 98 ms
10,368 KB |
testcase_59 | AC | 95 ms
13,824 KB |
testcase_60 | AC | 158 ms
16,512 KB |
testcase_61 | AC | 59 ms
8,832 KB |
testcase_62 | AC | 131 ms
13,952 KB |
testcase_63 | AC | 110 ms
10,752 KB |
testcase_64 | AC | 83 ms
10,368 KB |
testcase_65 | AC | 45 ms
9,344 KB |
testcase_66 | AC | 62 ms
9,344 KB |
testcase_67 | AC | 62 ms
10,496 KB |
testcase_68 | AC | 107 ms
15,232 KB |
testcase_69 | AC | 64 ms
10,112 KB |
testcase_70 | AC | 143 ms
16,384 KB |
testcase_71 | AC | 108 ms
13,440 KB |
testcase_72 | AC | 150 ms
16,640 KB |
testcase_73 | AC | 149 ms
15,104 KB |
testcase_74 | AC | 119 ms
12,800 KB |
testcase_75 | AC | 122 ms
14,080 KB |
testcase_76 | AC | 107 ms
13,056 KB |
testcase_77 | AC | 122 ms
13,440 KB |
testcase_78 | AC | 121 ms
14,336 KB |
testcase_79 | AC | 162 ms
17,280 KB |
testcase_80 | AC | 140 ms
16,768 KB |
testcase_81 | AC | 114 ms
13,056 KB |
testcase_82 | AC | 137 ms
14,336 KB |
testcase_83 | AC | 140 ms
15,872 KB |
testcase_84 | AC | 111 ms
13,312 KB |
testcase_85 | AC | 168 ms
17,536 KB |
testcase_86 | AC | 126 ms
14,080 KB |
testcase_87 | AC | 154 ms
16,256 KB |
testcase_88 | AC | 118 ms
13,056 KB |
testcase_89 | AC | 126 ms
15,360 KB |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | WA | - |
testcase_93 | WA | - |
testcase_94 | WA | - |
testcase_95 | AC | 180 ms
18,816 KB |
ソースコード
//@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; }