結果
問題 | No.1233 割り切れない気持ち |
ユーザー | t33f |
提出日時 | 2020-09-18 21:41:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.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 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 39 |
コンパイルメッセージ
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) { | ^
ソースコード
#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; }