結果

問題 No.2486 Don't come next to me
ユーザー planesplanes
提出日時 2023-09-29 21:17:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 1,961 ms
コンパイル使用メモリ 165,864 KB
実行使用メモリ 4,860 KB
最終ジャッジ日時 2023-09-29 21:18:04
合計ジャッジ時間 3,777 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
4,380 KB
testcase_01 AC 32 ms
4,436 KB
testcase_02 AC 10 ms
4,380 KB
testcase_03 AC 23 ms
4,380 KB
testcase_04 AC 31 ms
4,376 KB
testcase_05 AC 23 ms
4,380 KB
testcase_06 AC 26 ms
4,376 KB
testcase_07 AC 6 ms
4,376 KB
testcase_08 AC 11 ms
4,376 KB
testcase_09 AC 31 ms
4,380 KB
testcase_10 AC 24 ms
4,376 KB
testcase_11 AC 15 ms
4,380 KB
testcase_12 AC 7 ms
4,380 KB
testcase_13 AC 41 ms
4,860 KB
testcase_14 AC 12 ms
4,376 KB
testcase_15 AC 24 ms
4,376 KB
testcase_16 AC 6 ms
4,376 KB
testcase_17 AC 10 ms
4,380 KB
testcase_18 AC 10 ms
4,380 KB
testcase_19 AC 11 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

  #include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

ll INF=2e18;


int main() {
    ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll N,M;cin>>N>>M;
  vector<ll> A(M);
  for(ll i=0;i<M;i++) cin>>A[i];

  ll ans=0;
  for(ll i=0;i<M-1;i++) {
    ll s=A[i+1]-A[i]-1;
ll count=1;
    while(s%2!=0&&s>1) {
      s/=2;
      count*=2;
    }
    ans+=s*count;
  }

  cout<<ans<<endl;
}
0