結果

問題 No.1233 割り切れない気持ち
ユーザー t33ft33f
提出日時 2020-09-18 21:41:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 504 ms / 3,153 ms
コード長 683 bytes
コンパイル時間 930 ms
コンパイル使用メモリ 83,388 KB
実行使用メモリ 14,784 KB
最終ジャッジ日時 2023-09-04 21:43:43
合計ジャッジ時間 7,846 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 10 ms
4,380 KB
testcase_03 AC 27 ms
4,380 KB
testcase_04 AC 21 ms
4,380 KB
testcase_05 AC 13 ms
4,388 KB
testcase_06 AC 14 ms
4,380 KB
testcase_07 AC 132 ms
5,176 KB
testcase_08 AC 182 ms
6,440 KB
testcase_09 AC 305 ms
9,644 KB
testcase_10 AC 323 ms
9,828 KB
testcase_11 AC 111 ms
4,948 KB
testcase_12 AC 368 ms
10,628 KB
testcase_13 AC 351 ms
10,580 KB
testcase_14 AC 358 ms
10,564 KB
testcase_15 AC 373 ms
10,712 KB
testcase_16 AC 380 ms
10,572 KB
testcase_17 AC 37 ms
5,976 KB
testcase_18 AC 504 ms
14,784 KB
testcase_19 AC 65 ms
5,708 KB
testcase_20 AC 45 ms
5,760 KB
testcase_21 AC 55 ms
5,700 KB
testcase_22 AC 55 ms
5,892 KB
testcase_23 AC 54 ms
5,904 KB
testcase_24 AC 54 ms
5,720 KB
testcase_25 AC 53 ms
5,700 KB
testcase_26 AC 53 ms
5,712 KB
testcase_27 AC 62 ms
5,740 KB
testcase_28 AC 61 ms
5,720 KB
testcase_29 AC 62 ms
6,000 KB
testcase_30 AC 61 ms
5,708 KB
testcase_31 AC 61 ms
5,716 KB
testcase_32 AC 62 ms
5,736 KB
testcase_33 AC 61 ms
5,724 KB
testcase_34 AC 62 ms
5,704 KB
testcase_35 AC 61 ms
5,736 KB
testcase_36 AC 61 ms
5,820 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 45 ms
5,708 KB
testcase_39 AC 271 ms
10,136 KB
testcase_40 AC 271 ms
10,388 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:18:15: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   18 |     for (auto [x, c] : cnt) {
      |               ^

ソースコード

diff #

#include <unordered_map>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n];
    long long s[n+1];
    s[0] = 0;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    for (int i = 0; i < n; i++) {
        s[i+1] = s[i] + a[i];
    }
    long long ans = 0;
    unordered_map<int, int> cnt;
    for (int i = 0; i < n; i++) cnt[a[i]]++;
    for (auto [x, c] : cnt) {
        for (int m = 0; m <= 2e5; m += x) {
            int l = lower_bound(a, a+n, m) - a,
                r = lower_bound(a, a+n, m+x) - a;
            ans += c * (s[r] - s[l] - (long long)m * (r - l));
        }
    }
    cout << ans << endl;
}
0