結果
問題 |
No.2486 Don't come next to me
|
ユーザー |
|
提出日時 | 2023-09-29 21:38:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 501 bytes |
コンパイル時間 | 2,088 ms |
コンパイル使用メモリ | 199,404 KB |
最終ジャッジ日時 | 2025-02-17 03:10:48 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | WA * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(int i=0;i<(int)(n);i++) int main(){ ll n,m; cin>>n>>m; vector<ll> a(m); rep(i,m) cin>>a.at(i); ll ans=0; if(a.back()==n-1) ans++; if(a.back()<=n-1){ a.push_back(n); m++; } if(a.at(0)==2) ans++; if(a.at(0)>=2){ a.push_back(1); m++; } sort(a.begin(),a.end()); rep(i,m-1){ ll df=a.at(i+1)-a.at(i)-1; if(df==0) continue; if(df!=1){ if(df&1) df--; } ans+=df; } cout<<ans<<endl; }