結果

問題 No.2486 Don't come next to me
ユーザー highlighterhighlighter
提出日時 2023-09-28 07:54:55
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 355 bytes
コンパイル時間 2,912 ms
コンパイル使用メモリ 245,168 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-21 02:22:16
合計ジャッジ時間 5,609 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int uint64_t

int f(int N){
	if(__builtin_popcount(N+1)==1) return N/2;
	int ans=(N+1)&(-N-1);
    return ans-1;
}

signed main() {
	int N,M;
	cin >> N >> M;
	vector<int> A(M);
	for(int &i : A){
		cin >> i;
	}
	int ans=0;
	for(int i=0;i<M-1;i++){
		ans+=f(A[i+1]-A[i]-1);
	}
	cout << N-M-ans << endl;
}
0