結果

問題 No.2486 Don't come next to me
ユーザー umezoumezo
提出日時 2023-09-29 22:15:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 506 bytes
コンパイル時間 2,899 ms
コンパイル使用メモリ 199,684 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-29 22:15:56
合計ジャッジ時間 6,284 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 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);
  
  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