結果
問題 | No.1262 グラフを作ろう! |
ユーザー | suta28407928 |
提出日時 | 2020-10-17 01:36:23 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 416 ms / 3,000 ms |
コード長 | 2,271 bytes |
コンパイル時間 | 1,355 ms |
コンパイル使用メモリ | 114,160 KB |
実行使用メモリ | 26,752 KB |
最終ジャッジ日時 | 2024-07-21 01:39:25 |
合計ジャッジ時間 | 31,476 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 282 ms
17,152 KB |
testcase_01 | AC | 216 ms
13,696 KB |
testcase_02 | AC | 317 ms
20,096 KB |
testcase_03 | AC | 291 ms
13,824 KB |
testcase_04 | AC | 98 ms
16,128 KB |
testcase_05 | AC | 171 ms
15,232 KB |
testcase_06 | AC | 151 ms
18,304 KB |
testcase_07 | AC | 43 ms
6,656 KB |
testcase_08 | AC | 249 ms
20,480 KB |
testcase_09 | AC | 190 ms
10,368 KB |
testcase_10 | AC | 142 ms
11,776 KB |
testcase_11 | AC | 245 ms
21,888 KB |
testcase_12 | AC | 265 ms
16,128 KB |
testcase_13 | AC | 285 ms
14,464 KB |
testcase_14 | AC | 129 ms
12,416 KB |
testcase_15 | AC | 144 ms
8,960 KB |
testcase_16 | AC | 254 ms
19,712 KB |
testcase_17 | AC | 213 ms
17,152 KB |
testcase_18 | AC | 327 ms
21,888 KB |
testcase_19 | AC | 92 ms
14,848 KB |
testcase_20 | AC | 200 ms
20,864 KB |
testcase_21 | AC | 328 ms
20,608 KB |
testcase_22 | AC | 69 ms
13,696 KB |
testcase_23 | AC | 168 ms
11,136 KB |
testcase_24 | AC | 242 ms
20,352 KB |
testcase_25 | AC | 59 ms
10,240 KB |
testcase_26 | AC | 97 ms
12,032 KB |
testcase_27 | AC | 188 ms
18,048 KB |
testcase_28 | AC | 144 ms
15,872 KB |
testcase_29 | AC | 161 ms
16,512 KB |
testcase_30 | AC | 115 ms
12,544 KB |
testcase_31 | AC | 342 ms
18,048 KB |
testcase_32 | AC | 184 ms
14,848 KB |
testcase_33 | AC | 80 ms
7,040 KB |
testcase_34 | AC | 209 ms
21,248 KB |
testcase_35 | AC | 252 ms
14,464 KB |
testcase_36 | AC | 93 ms
7,040 KB |
testcase_37 | AC | 382 ms
22,400 KB |
testcase_38 | AC | 217 ms
17,280 KB |
testcase_39 | AC | 181 ms
10,368 KB |
testcase_40 | AC | 149 ms
11,776 KB |
testcase_41 | AC | 144 ms
17,792 KB |
testcase_42 | AC | 294 ms
21,632 KB |
testcase_43 | AC | 196 ms
15,360 KB |
testcase_44 | AC | 170 ms
14,848 KB |
testcase_45 | AC | 294 ms
22,272 KB |
testcase_46 | AC | 231 ms
19,712 KB |
testcase_47 | AC | 203 ms
10,624 KB |
testcase_48 | AC | 269 ms
19,840 KB |
testcase_49 | AC | 391 ms
21,760 KB |
testcase_50 | AC | 354 ms
21,632 KB |
testcase_51 | AC | 296 ms
12,160 KB |
testcase_52 | AC | 183 ms
19,072 KB |
testcase_53 | AC | 59 ms
8,576 KB |
testcase_54 | AC | 308 ms
16,640 KB |
testcase_55 | AC | 222 ms
15,232 KB |
testcase_56 | AC | 150 ms
17,280 KB |
testcase_57 | AC | 384 ms
24,960 KB |
testcase_58 | AC | 283 ms
14,976 KB |
testcase_59 | AC | 225 ms
18,048 KB |
testcase_60 | AC | 352 ms
23,424 KB |
testcase_61 | AC | 144 ms
11,776 KB |
testcase_62 | AC | 332 ms
19,840 KB |
testcase_63 | AC | 304 ms
15,872 KB |
testcase_64 | AC | 219 ms
14,336 KB |
testcase_65 | AC | 80 ms
11,648 KB |
testcase_66 | AC | 139 ms
12,544 KB |
testcase_67 | AC | 116 ms
13,568 KB |
testcase_68 | AC | 150 ms
19,456 KB |
testcase_69 | AC | 130 ms
13,056 KB |
testcase_70 | AC | 387 ms
22,528 KB |
testcase_71 | AC | 300 ms
18,304 KB |
testcase_72 | AC | 377 ms
23,296 KB |
testcase_73 | AC | 341 ms
21,888 KB |
testcase_74 | AC | 364 ms
18,432 KB |
testcase_75 | AC | 314 ms
19,456 KB |
testcase_76 | AC | 219 ms
17,792 KB |
testcase_77 | AC | 297 ms
18,944 KB |
testcase_78 | AC | 326 ms
19,712 KB |
testcase_79 | AC | 409 ms
24,320 KB |
testcase_80 | AC | 328 ms
22,656 KB |
testcase_81 | AC | 345 ms
18,432 KB |
testcase_82 | AC | 348 ms
20,608 KB |
testcase_83 | AC | 271 ms
21,760 KB |
testcase_84 | AC | 274 ms
18,304 KB |
testcase_85 | AC | 416 ms
24,704 KB |
testcase_86 | AC | 354 ms
19,712 KB |
testcase_87 | AC | 383 ms
22,912 KB |
testcase_88 | AC | 292 ms
18,560 KB |
testcase_89 | AC | 269 ms
20,736 KB |
testcase_90 | AC | 385 ms
26,624 KB |
testcase_91 | AC | 396 ms
26,624 KB |
testcase_92 | AC | 395 ms
26,624 KB |
testcase_93 | AC | 415 ms
26,752 KB |
testcase_94 | AC | 398 ms
26,624 KB |
testcase_95 | AC | 396 ms
26,752 KB |
ソースコード
#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <iostream> #include <string> #include <cstdlib> #include <cmath> #include <vector> #include <unordered_map> #include <map> #include <set> #include <algorithm> #include <queue> #include <stack> #include <functional> #include <bitset> #include <assert.h> #include <unordered_map> #include <fstream> #include <ctime> #include <complex> using namespace std; typedef long long ll; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<char> vc; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<double> vd; typedef pair<ll,ll> P; typedef pair<int,int> pii; typedef vector<P> vpl; typedef tuple<ll,ll,ll> tapu; #define rep(i,n) for(int i=0; i<(n); i++) #define REP(i,a,b) for(int i=(a); i<(b); i++) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() const int inf = 1<<30; const ll linf = 1LL<<62; const int MAX = 1020000; ll dy[8] = {1,-1,0,0,1,-1,1,-1}; ll dx[8] = {0,0,1,-1,1,-1,-1,1}; const double pi = acos(-1); const double eps = 1e-10; template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){ if(a>b){ a = b; return true; } else return false; } template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){ if(a<b){ a = b; return true; } else return false; } template<typename T> inline void print(T &a){ for(auto itr = a.begin(); itr != a.end(); itr++){ cout << *itr << " "; } cout << "\n"; } template<typename T1,typename T2> inline void print2(T1 a, T2 b){ cout << "debug: " << a << " " << b << "\n"; } template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){ cout << "debug: " << a << " " << b << " " << c << "\n"; } void mark() {cout << "#" << "\n";} ll pcount(ll x) {return __builtin_popcountll(x);} const int mod = 1e9 + 7; //const int mod = 998244353; ll GCD(ll a, ll b){ if(b==0) return a; else return GCD(b,a%b); } int main(){ int n,m; cin >> n >> m; vl a(m); rep(i,m) cin >> a[i]; ll ans = 0; vl cnt(n+1,0); vl add(n+1,0); for(int i=1; i<=n; i++){ add[i] += i; cnt[i] += add[i]; for(int j=i+i; j<=n; j+=i){ cnt[j] += add[i] * (j / i); add[j] -= add[i]; } } rep(i,m){ ans += cnt[a[i]] - a[i]; } cout << ans << "\n"; }