結果

問題 No.1233 割り切れない気持ち
ユーザー yurujirouyurujirou
提出日時 2021-09-22 21:20:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 568 ms / 3,153 ms
コード長 1,215 bytes
コンパイル時間 1,478 ms
コンパイル使用メモリ 79,248 KB
実行使用メモリ 7,096 KB
最終ジャッジ日時 2023-09-18 19:43:24
合計ジャッジ時間 11,824 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,464 KB
testcase_01 AC 6 ms
5,516 KB
testcase_02 AC 7 ms
5,360 KB
testcase_03 AC 10 ms
5,676 KB
testcase_04 AC 10 ms
5,400 KB
testcase_05 AC 8 ms
5,420 KB
testcase_06 AC 7 ms
5,460 KB
testcase_07 AC 132 ms
5,776 KB
testcase_08 AC 230 ms
6,160 KB
testcase_09 AC 451 ms
6,744 KB
testcase_10 AC 485 ms
6,884 KB
testcase_11 AC 118 ms
5,780 KB
testcase_12 AC 566 ms
6,976 KB
testcase_13 AC 566 ms
6,964 KB
testcase_14 AC 568 ms
6,936 KB
testcase_15 AC 566 ms
6,968 KB
testcase_16 AC 566 ms
7,096 KB
testcase_17 AC 43 ms
5,376 KB
testcase_18 AC 553 ms
7,008 KB
testcase_19 AC 164 ms
5,392 KB
testcase_20 AC 43 ms
5,656 KB
testcase_21 AC 61 ms
5,552 KB
testcase_22 AC 61 ms
5,464 KB
testcase_23 AC 60 ms
5,480 KB
testcase_24 AC 61 ms
5,392 KB
testcase_25 AC 61 ms
5,516 KB
testcase_26 AC 61 ms
5,628 KB
testcase_27 AC 201 ms
6,256 KB
testcase_28 AC 200 ms
6,260 KB
testcase_29 AC 199 ms
6,068 KB
testcase_30 AC 197 ms
6,020 KB
testcase_31 AC 195 ms
5,980 KB
testcase_32 AC 194 ms
5,952 KB
testcase_33 AC 192 ms
5,888 KB
testcase_34 AC 191 ms
5,880 KB
testcase_35 AC 190 ms
5,980 KB
testcase_36 AC 188 ms
5,884 KB
testcase_37 AC 4 ms
5,516 KB
testcase_38 AC 158 ms
5,396 KB
testcase_39 AC 487 ms
6,976 KB
testcase_40 AC 488 ms
7,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>
using namespace std;

//#include <atcoder/all>
//using namespace atcoder;

#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 LREP(i,n) for(LL i = 0; i < (LL)n; i++)

#define Vi vector<int>
#define Vl vector<long long>
#define LP pair<long long ,long long>
#define P pair<int, int>
#define T3 tuple<LL, LL, LL>
#define T4 tuple<LL, LL, LL, LL>
#define INF 1000000007
#define SIZE	300010
#define MOD 1000000007
typedef long long LL;

LL N, S;
LL A[SIZE], B[SIZE];

int main() {
	cin >> N;
	REP(i, N) cin >> A[i];
	REP(i, N) S += A[i];
	REP(i, N) B[A[i]] += 1;
	sort(A, A + N);

	LL ans = 0;
	for (LL i = 1; i < SIZE; i++) {
		LL a = i, cost = S;
		for (LL l = 0; l <= A[N - 1]; l += a) {
			LL r = l + a;
			LL cnt = lower_bound(A, A + N, r) - lower_bound(A, A + N, l);
			cost -= l * cnt;
		}
		ans += cost * B[i];
	}
	cout << ans << endl;
}
0