結果
問題 | No.2486 Don't come next to me |
ユーザー |
|
提出日時 | 2023-09-29 21:44:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 4,329 bytes |
コンパイル時間 | 1,847 ms |
コンパイル使用メモリ | 182,108 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-22 15:45:51 |
合計ジャッジ時間 | 7,373 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | RE * 20 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;using ld = long double;using pii = pair<int, int>;using pli = pair<ll, int>;using pll = pair<ll, ll>;const string Yes="Yes";const string No="No";const string YES="YES";const string NO="NO";const string abc="ABCDEFGHIJKLMNOPQRSTUVWXYZ";const ll MOD=1000000007;const ll mod=998244353;const ll big_prime=(1LL << 61)-1;const long long INF = 1LL << 60;const long double PI=3.141592653589793;#define pb push_back#define mp make_pair#define all(x) (x).begin(), (x).end()#define fi first#define se second#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}#define inV(vec) for(ll i=0;i<vec.size();i++)cin>>vec[i];#define outV(vec) for(ll i=0;i<vec.size();i++){cout<<vec[i]<<" ";}cout<<endl;#define print(s) cout<<s<<endl;template <typename T>inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }template <typename T>inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }#pragma GCC target("avx")#pragma GCC optimize("O3")#pragma GCC optimize("unroll-loops")#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")#define rep(i, n) for (int i = 0; i < (int)(n); i++)//エラトステネスの篩vector<bool>Prime(2,false);//false=not Prime number, true=Prime Numbervoid Era(ll N){for(ll i=0;i<N-1;i++){Prime.pb(true);}for(ll i=2;i*i<=N;i++){if(Prime[i]){for(ll x=2*i;x<=N;x+=i)Prime[x]=false;}}}//繰り返し二乗法ll modpow(ll a, ll n, ll mod) {if(a==0){return 0;}ll res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}//素因数分解vector<pair<long long, long long> > prime_factorize(long long N) {vector<pair<long long, long long> > res;for (long long a = 2; a * a <= N; ++a) {if (N % a != 0) continue;long long ex = 0; // 指数// 割れる限り割り続けるwhile (N % a == 0) {++ex;N /= a;}// その結果を pushres.push_back({a, ex});}// 最後に残った数についてif (N != 1) res.push_back({N, 1});return res;}//割り算ll Div(ll a,ll b,ll m){return (a * modpow(b,m-2,m)) % m;}//階乗vector<ll>fact(1);void fac(ll N,ll m){fact[0]=1;for(int i=1;i<=N;i++){fact.pb(fact[i-1]*(i));fact[i]%=m;}}//組み合わせll comb(ll n,ll r,ll m){return Div(fact[n],fact[r] * fact[n-r] % m,m);}//UnionFindstruct UnionFind {vector<int> par, rank, siz;// 構造体の初期化UnionFind(int n) : par(n,-1), rank(n,0), siz(n,1) { }// 根を求めるint root(int x) {if (par[x]==-1) return x; // x が根の場合は x を返すelse return par[x] = root(par[x]); // 経路圧縮}// x と y が同じグループに属するか (= 根が一致するか)bool same(int x, int y) {return root(x)==root(y);}// x を含むグループと y を含むグループを併合するbool unite(int x, int y) {int rx = root(x), ry = root(y); // x 側と y 側の根を取得するif (rx==ry) return false; // すでに同じグループのときは何もしない// union by rankif (rank[rx]<rank[ry]) swap(rx, ry); // ry 側の rank が小さくなるようにするpar[ry] = rx; // ry を rx の子とするif (rank[rx]==rank[ry]) rank[rx]++; // rx 側の rank を調整するsiz[rx] += siz[ry]; // rx 側の siz を調整するreturn true;}// x を含む根付き木のサイズを求めるint size(int x) {return siz[root(x)];}};//https://algo-method.com/descriptions/136int main(){vector<ll>dp(200001);dp[2]=2;dp[1]=1;for(int i=2;i<=200000;i++){if(i%2==0){dp[i]=i;}else{dp[i]=dp[i/2]*2;}}ll N,M;cin>>N>>M;vector<ll>A(M);inV(A);ll ans=0;for(int i=0;i<M-1;i++){ans+=dp[A[i+1]-A[i]-1];}print(ans);}