結果

問題 No.1268 Fruit Rush 2
ユーザー hanyuhanyu
提出日時 2020-10-17 16:46:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 280 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 2,441 ms
コンパイル使用メモリ 210,668 KB
実行使用メモリ 25,448 KB
最終ジャッジ日時 2023-09-28 08:23:09
合計ジャッジ時間 10,151 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 191 ms
20,176 KB
testcase_17 AC 161 ms
17,716 KB
testcase_18 AC 171 ms
18,620 KB
testcase_19 AC 167 ms
18,368 KB
testcase_20 AC 164 ms
18,168 KB
testcase_21 AC 161 ms
17,828 KB
testcase_22 AC 199 ms
20,096 KB
testcase_23 AC 198 ms
20,196 KB
testcase_24 AC 168 ms
18,352 KB
testcase_25 AC 160 ms
18,208 KB
testcase_26 AC 256 ms
25,200 KB
testcase_27 AC 252 ms
25,172 KB
testcase_28 AC 257 ms
25,208 KB
testcase_29 AC 256 ms
25,204 KB
testcase_30 AC 253 ms
25,448 KB
testcase_31 AC 279 ms
25,328 KB
testcase_32 AC 280 ms
25,204 KB
testcase_33 AC 262 ms
25,320 KB
testcase_34 AC 246 ms
25,228 KB
testcase_35 AC 266 ms
25,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  set<ll> s;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    s.insert(a);
  }
  
  map<ll, ll> mp;
  ll ans = n;
  for (auto &f : s) {
    ll count = 0;
    if (s.find(f - 1) != s.end()) count++;
    if (mp.find(f - 1) != mp.end()) count += mp[f - 1];
    mp[f + 1] = count;
    ans += count;
  }
  
  cout << ans << '\n';
}
0