結果

問題 No.1233 割り切れない気持ち
ユーザー t33ft33f
提出日時 2020-09-18 21:41:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 445 ms / 3,153 ms
コード長 683 bytes
コンパイル時間 906 ms
コンパイル使用メモリ 84,168 KB
実行使用メモリ 15,140 KB
最終ジャッジ日時 2024-06-22 19:11:53
合計ジャッジ時間 6,867 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 9 ms
6,940 KB
testcase_03 AC 24 ms
6,940 KB
testcase_04 AC 18 ms
6,944 KB
testcase_05 AC 12 ms
6,944 KB
testcase_06 AC 13 ms
6,944 KB
testcase_07 AC 124 ms
6,940 KB
testcase_08 AC 170 ms
6,944 KB
testcase_09 AC 278 ms
9,864 KB
testcase_10 AC 291 ms
10,104 KB
testcase_11 AC 99 ms
6,940 KB
testcase_12 AC 340 ms
10,912 KB
testcase_13 AC 316 ms
11,040 KB
testcase_14 AC 316 ms
11,012 KB
testcase_15 AC 339 ms
10,912 KB
testcase_16 AC 339 ms
10,916 KB
testcase_17 AC 36 ms
6,940 KB
testcase_18 AC 445 ms
15,140 KB
testcase_19 AC 62 ms
6,940 KB
testcase_20 AC 44 ms
6,944 KB
testcase_21 AC 52 ms
6,940 KB
testcase_22 AC 51 ms
6,944 KB
testcase_23 AC 52 ms
6,944 KB
testcase_24 AC 53 ms
6,944 KB
testcase_25 AC 51 ms
6,940 KB
testcase_26 AC 52 ms
6,944 KB
testcase_27 AC 58 ms
6,940 KB
testcase_28 AC 58 ms
6,940 KB
testcase_29 AC 59 ms
6,940 KB
testcase_30 AC 59 ms
6,944 KB
testcase_31 AC 58 ms
6,940 KB
testcase_32 AC 58 ms
6,944 KB
testcase_33 AC 58 ms
6,944 KB
testcase_34 AC 59 ms
6,944 KB
testcase_35 AC 58 ms
6,940 KB
testcase_36 AC 57 ms
6,944 KB
testcase_37 AC 2 ms
6,940 KB
testcase_38 AC 44 ms
6,944 KB
testcase_39 AC 245 ms
10,412 KB
testcase_40 AC 246 ms
10,412 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:18:15: warning: 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