結果

問題 No.1268 Fruit Rush 2
ユーザー tonyu0tonyu0
提出日時 2020-10-24 08:44:25
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 384 ms / 2,000 ms
コード長 672 bytes
コンパイル時間 1,852 ms
コンパイル使用メモリ 127,852 KB
実行使用メモリ 29,188 KB
最終ジャッジ日時 2023-09-28 20:09:58
合計ジャッジ時間 7,093 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 85 ms
13,980 KB
testcase_17 AC 77 ms
13,480 KB
testcase_18 AC 81 ms
13,800 KB
testcase_19 AC 79 ms
13,672 KB
testcase_20 AC 77 ms
13,456 KB
testcase_21 AC 78 ms
13,600 KB
testcase_22 AC 86 ms
13,784 KB
testcase_23 AC 86 ms
13,600 KB
testcase_24 AC 80 ms
13,564 KB
testcase_25 AC 79 ms
13,608 KB
testcase_26 AC 384 ms
29,020 KB
testcase_27 AC 379 ms
29,188 KB
testcase_28 AC 376 ms
28,912 KB
testcase_29 AC 380 ms
28,928 KB
testcase_30 AC 375 ms
28,864 KB
testcase_31 AC 102 ms
14,120 KB
testcase_32 AC 103 ms
14,168 KB
testcase_33 AC 159 ms
14,304 KB
testcase_34 AC 116 ms
23,824 KB
testcase_35 AC 185 ms
23,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (n); ++i)
#define rrep(i, j, n) for (int i = (n)-1; j <= i; --i)

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, 0, n) cin >> a[i];
  sort(a.begin(), a.end());
  // 重複は一個前
  unordered_map<ll, ll> dp;
  rep(i, 0, n) {
    ++dp[a[i]];
    dp[a[i] + 1] += dp[a[i] - 1];
  }
  ll ans = 0;
  for (auto itr : dp) ans += itr.second;
  cout << ans << endl;
  return 0;
}
0