結果

問題 No.1268 Fruit Rush 2
ユーザー SSRSSSRS
提出日時 2020-10-23 22:33:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 250 ms / 2,000 ms
コード長 792 bytes
コンパイル時間 1,919 ms
コンパイル使用メモリ 181,292 KB
実行使用メモリ 25,448 KB
最終ジャッジ日時 2023-09-28 16:39:23
合計ジャッジ時間 7,425 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 154 ms
14,672 KB
testcase_17 AC 134 ms
13,444 KB
testcase_18 AC 140 ms
13,844 KB
testcase_19 AC 140 ms
13,560 KB
testcase_20 AC 138 ms
13,576 KB
testcase_21 AC 136 ms
13,672 KB
testcase_22 AC 156 ms
14,700 KB
testcase_23 AC 155 ms
14,524 KB
testcase_24 AC 139 ms
13,740 KB
testcase_25 AC 135 ms
13,688 KB
testcase_26 AC 237 ms
25,448 KB
testcase_27 AC 241 ms
25,292 KB
testcase_28 AC 240 ms
25,440 KB
testcase_29 AC 240 ms
25,184 KB
testcase_30 AC 238 ms
25,268 KB
testcase_31 AC 195 ms
15,876 KB
testcase_32 AC 195 ms
15,808 KB
testcase_33 AC 250 ms
15,796 KB
testcase_34 AC 177 ms
16,068 KB
testcase_35 AC 246 ms
16,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A.rbegin(), A.rend());
  set<long long> st;
  for (int i = 0; i < N; i++){
    st.insert(A[i]);
  }
  vector<vector<vector<long long>>> P(2);
  for (int i = 0; i < N; i++){
    int r = A[i] % 2;
    if (st.count(A[i] + 2)){
      P[r].back().push_back(A[i]);
    } else {
      P[r].push_back(vector<long long>(1, A[i]));
    }
  }
  long long ans = N;
  for (int i = 0; i < 2; i++){
    int cnt = P[i].size();
    for (int j = 0; j < cnt; j++){
      int sz = P[i][j].size();
      for (int k = 0; k < sz; k++){
        if (st.count(P[i][j][k] - 1)){
          ans += k + 1;
        }
      }
    }
  }
  cout << ans << endl;
}
0