結果

問題 No.2486 Don't come next to me
ユーザー umezoumezo
提出日時 2023-09-29 22:25:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 421 ms / 2,000 ms
コード長 574 bytes
コンパイル時間 2,295 ms
コンパイル使用メモリ 210,708 KB
実行使用メモリ 31,048 KB
最終ジャッジ日時 2023-09-29 22:25:29
合計ジャッジ時間 7,944 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 324 ms
27,148 KB
testcase_01 AC 289 ms
24,620 KB
testcase_02 AC 57 ms
9,428 KB
testcase_03 AC 178 ms
18,392 KB
testcase_04 AC 260 ms
23,708 KB
testcase_05 AC 179 ms
18,312 KB
testcase_06 AC 241 ms
20,116 KB
testcase_07 AC 25 ms
6,140 KB
testcase_08 AC 59 ms
9,576 KB
testcase_09 AC 283 ms
25,144 KB
testcase_10 AC 196 ms
18,808 KB
testcase_11 AC 97 ms
12,468 KB
testcase_12 AC 36 ms
7,452 KB
testcase_13 AC 421 ms
31,048 KB
testcase_14 AC 71 ms
10,612 KB
testcase_15 AC 182 ms
18,544 KB
testcase_16 AC 28 ms
6,516 KB
testcase_17 AC 64 ms
9,748 KB
testcase_18 AC 55 ms
8,896 KB
testcase_19 AC 65 ms
10,132 KB
testcase_20 AC 2 ms
4,384 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll n,m;
  cin>>n>>m;
  vector<ll> A(m);
  rep(i,m) cin>>A[i];
  vector<ll> B(m-1);
  rep(i,m-1) B[i]=A[i+1]-A[i]-1;
  
  map<ll,ll> M;
  M[1]=1;
  auto f=[&](auto f,ll x)->ll{
    if(M.count(x)) return M[x];
    if(x%2==0) return M[x]=x;
    return M[x]=2*f(f,x/2);
  };
  
  ll ans=0;
  rep(i,m-1) ans+=f(f,B[i]);
  cout<<ans<<endl;
    
  return 0;
}
0