結果

問題 No.2486 Don't come next to me
ユーザー umezo
提出日時 2023-09-29 22:15:49
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 506 bytes
コンパイル時間 5,708 ms
コンパイル使用メモリ 255,580 KB
最終ジャッジ日時 2025-02-17 03:20:38
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other RE * 20
権限があれば一括ダウンロードができます

ソースコード

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);
  
  int 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;
  ll ans=0;
  rep(i,m-1){
    if(B[i]==1 || B[i]%2==0) ans+=B[i];
    else if(B[i]%4==1) ans+=B[i]-1;
    else ans+=B[i]/2+1;
  }
  cout<<ans<<endl;
    
  return 0;
}
0