結果

問題 No.1268 Fruit Rush 2
ユーザー hanyuhanyu
提出日時 2020-05-31 15:46:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 694 bytes
コンパイル時間 2,449 ms
コンパイル使用メモリ 166,888 KB
実行使用メモリ 16,196 KB
最終ジャッジ日時 2023-09-04 08:33:51
合計ジャッジ時間 7,598 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,504 KB
testcase_01 AC 3 ms
4,516 KB
testcase_02 AC 3 ms
4,500 KB
testcase_03 AC 3 ms
4,572 KB
testcase_04 AC 3 ms
4,516 KB
testcase_05 AC 3 ms
4,616 KB
testcase_06 AC 3 ms
4,576 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 3 ms
4,680 KB
testcase_10 AC 3 ms
4,644 KB
testcase_11 AC 3 ms
4,660 KB
testcase_12 RE -
testcase_13 AC 3 ms
4,816 KB
testcase_14 AC 4 ms
4,628 KB
testcase_15 RE -
testcase_16 AC 22 ms
4,516 KB
testcase_17 AC 19 ms
4,652 KB
testcase_18 AC 20 ms
4,604 KB
testcase_19 AC 20 ms
4,660 KB
testcase_20 AC 21 ms
4,564 KB
testcase_21 AC 20 ms
4,576 KB
testcase_22 AC 22 ms
4,560 KB
testcase_23 AC 23 ms
4,612 KB
testcase_24 AC 19 ms
4,688 KB
testcase_25 AC 20 ms
4,576 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 TLE -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// 愚直が撃墜されるか確認
#include <bits/stdc++.h>
using namespace std;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> exist(2e5, false);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    exist.at(a - 1) = true;
  }
  
  ll ans = n; // 1個だけ選ぶとき
  for (int i = 1; i < 2e5; i++) {
    if (exist.at(i - 1) && exist.at(i)) {
      ll cnt = 1, it = i;
      while (it < 2e5 - 2 && exist.at(it + 2)) {
        cnt++;
        it += 2;
      }
      ans += cnt;
    }
  }
  
  cout << ans << '\n';
}
0