結果

問題 No.1268 Fruit Rush 2
ユーザー butsurizukibutsurizuki
提出日時 2020-10-24 00:06:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 687 bytes
コンパイル時間 1,634 ms
コンパイル使用メモリ 173,396 KB
実行使用メモリ 22,972 KB
最終ジャッジ日時 2023-09-28 19:24:56
合計ジャッジ時間 7,269 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,680 KB
testcase_01 AC 4 ms
7,592 KB
testcase_02 AC 4 ms
7,508 KB
testcase_03 AC 4 ms
7,664 KB
testcase_04 AC 4 ms
7,528 KB
testcase_05 AC 4 ms
7,680 KB
testcase_06 AC 4 ms
7,708 KB
testcase_07 AC 4 ms
7,408 KB
testcase_08 AC 4 ms
7,724 KB
testcase_09 AC 4 ms
7,504 KB
testcase_10 AC 4 ms
7,424 KB
testcase_11 AC 4 ms
7,524 KB
testcase_12 AC 4 ms
7,544 KB
testcase_13 AC 4 ms
7,712 KB
testcase_14 AC 3 ms
7,492 KB
testcase_15 AC 4 ms
7,432 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 254 ms
18,588 KB
testcase_27 AC 252 ms
18,748 KB
testcase_28 AC 254 ms
18,584 KB
testcase_29 AC 254 ms
18,736 KB
testcase_30 AC 253 ms
18,732 KB
testcase_31 AC 234 ms
22,940 KB
testcase_32 AC 232 ms
22,972 KB
testcase_33 AC 201 ms
22,940 KB
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
long long mem[524288];
long long f(long long x){
  if(x==0){return 0;}
  if(mem[x]!=-1){return mem[x];}
  mem[x]=1+(x/2)+f(x-1);
  return mem[x];
}

int main(){
  for(int i=0;i<524288;i++){mem[i]=-1;}
  set<long long> st;
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    long long v;
    cin >> v;
    st.insert(v);
  }
  vector<long long> vc;
  for(auto x: st){
    vc.push_back(x);
  }
  vc.push_back(-1);
  long long c=1,res=0;
  for(int i=0;i<n;i++){
    //printf("%lld %lld\n",vc[i],vc[i+1]);
    if(vc[i]+1!=vc[i+1]){
      //printf("%lld\n",c);
      res+=f(c);
      c=1;
    }
    else{c++;}
  }
  cout << res << '\n';
  return 0;
}
0