結果

問題 No.1268 Fruit Rush 2
ユーザー butsurizukibutsurizuki
提出日時 2020-10-24 00:08:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 703 bytes
コンパイル時間 1,784 ms
コンパイル使用メモリ 171,744 KB
実行使用メモリ 21,464 KB
最終ジャッジ日時 2023-09-28 19:26:34
合計ジャッジ時間 7,188 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,440 KB
testcase_01 AC 4 ms
7,396 KB
testcase_02 AC 4 ms
7,448 KB
testcase_03 AC 4 ms
7,392 KB
testcase_04 AC 4 ms
7,492 KB
testcase_05 AC 3 ms
7,488 KB
testcase_06 AC 4 ms
7,436 KB
testcase_07 AC 4 ms
7,408 KB
testcase_08 AC 4 ms
7,704 KB
testcase_09 AC 3 ms
7,392 KB
testcase_10 AC 4 ms
7,400 KB
testcase_11 AC 4 ms
7,420 KB
testcase_12 AC 4 ms
7,412 KB
testcase_13 AC 4 ms
7,440 KB
testcase_14 AC 4 ms
7,572 KB
testcase_15 AC 4 ms
7,440 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 249 ms
18,580 KB
testcase_27 AC 239 ms
18,796 KB
testcase_28 AC 237 ms
18,660 KB
testcase_29 AC 238 ms
18,536 KB
testcase_30 AC 247 ms
18,660 KB
testcase_31 AC 221 ms
21,296 KB
testcase_32 AC 223 ms
21,464 KB
testcase_33 AC 200 ms
21,156 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]=f(x-1)+(long long)(x/2)+1ll;
  
  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