結果

問題 No.1233 割り切れない気持ち
ユーザー yataro800yataro800
提出日時 2023-01-09 14:30:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,336 bytes
コンパイル時間 4,066 ms
コンパイル使用メモリ 229,148 KB
実行使用メモリ 10,664 KB
最終ジャッジ日時 2023-08-22 17:43:58
合計ジャッジ時間 22,669 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,664 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 64 ms
4,380 KB
testcase_08 AC 110 ms
4,460 KB
testcase_09 AC 226 ms
5,736 KB
testcase_10 AC 242 ms
5,764 KB
testcase_11 AC 53 ms
4,380 KB
testcase_12 AC 292 ms
6,220 KB
testcase_13 AC 280 ms
6,272 KB
testcase_14 AC 291 ms
6,240 KB
testcase_15 AC 289 ms
6,356 KB
testcase_16 AC 300 ms
6,528 KB
testcase_17 AC 42 ms
6,244 KB
testcase_18 AC 293 ms
6,204 KB
testcase_19 AC 73 ms
6,240 KB
testcase_20 AC 43 ms
6,188 KB
testcase_21 AC 61 ms
6,340 KB
testcase_22 AC 61 ms
6,272 KB
testcase_23 AC 61 ms
6,344 KB
testcase_24 AC 61 ms
6,268 KB
testcase_25 AC 61 ms
6,280 KB
testcase_26 AC 61 ms
6,336 KB
testcase_27 AC 1,013 ms
6,236 KB
testcase_28 AC 910 ms
6,196 KB
testcase_29 AC 832 ms
6,280 KB
testcase_30 AC 769 ms
6,240 KB
testcase_31 AC 725 ms
6,284 KB
testcase_32 AC 677 ms
6,528 KB
testcase_33 AC 632 ms
6,360 KB
testcase_34 AC 600 ms
6,336 KB
testcase_35 AC 574 ms
6,220 KB
testcase_36 AC 550 ms
6,248 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 TLE -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <math.h>

#include <algorithm>
#include <array>
#include <atcoder/all>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using namespace atcoder;

using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  vector<ll> sumA(N + 1, 0);
  for (int i = 0; i < N; i++) {
    sumA[i + 1] = sumA[i] + A[i];
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ll prev = 0;
    for (ll j = 1; (j - 1) * A[i] <= A.back(); j++) {
      ll id = lower_bound(A.begin(), A.end(), j * A[i]) - A.begin();
      ans += (sumA[id] - sumA[prev]) - (j - 1) * A[i] * (id - prev);
      prev = id;
    }
    // cout << i << "," << ans << endl;
  }
  cout << ans << endl;

  return 0;
}
0