結果
問題 |
No.2486 Don't come next to me
|
ユーザー |
|
提出日時 | 2023-10-27 23:46:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 601 bytes |
コンパイル時間 | 1,896 ms |
コンパイル使用メモリ | 191,972 KB |
最終ジャッジ日時 | 2025-02-17 16:13:11 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; using pii=pair<int,int>; #define all(a) a.begin(),a.end() #define pb push_back #define sz(a) ((int)a.size()) const int N=200005; ll n,a[N]; int m; signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); cin >> n >> m; for(int i=0; i<m; ++i) cin >> a[i]; ll res=0; for(int i=0; i<m-1; ++i){ ll x=a[i+1]-a[i]-1,cnt=0; for(int j=0; j<77; ++j){ if(~x>>j&1) break; cnt+=1ll<<j; } if(cnt==x) res+=(x+1)/2; else res+=x-cnt; } cout << res << "\n"; }