Submission #973026

#TimeUsernameProblemLanguageResultExecution timeMemory
973026xuvxuvRabbit Carrot (LMIO19_triusis)C++14
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(i,a,b) for(auto i=a;i<b;i++) #define all(x) x.begin(),x.end() #define vpii vector<pair<int,int>> typedef pair<int,int> pii; typedef vector<int> vi; typedef map<int,int> mii; const int Prime1= 1000000007; const int Prime2= 998244353; long long binpow(long long a, long long b, long long m) { a %= m; long long res = 1; while (b > 0) { if (b & 1){ res = res * a % m;} a = a * a % m; b >>= 1; } return res; } vector<int> hp(int n){ vector<int>h(n,0) ; for(int i=2;i<n;i++){ h[i]=i; } for( int i=2;i*i<n;i++){ if(h[i]==i){ for(int j=i;j<n;j+=i){ h[j]=i; } } } return h; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m; cin>>n>>m; vi a(n); for(int i=0;i<n;i++){ cin>>a[i]; } int ans=0,cur=0; if(a[0]>m){ ans++; cur=1; a[0]=m; } for(int i=0;i<n-1;i++){ if(a[i+1]-a[i]<=m)continue; if(a[i+1]-a[i]>m && cur==0){ a[i]=a[i+1]-m; ans++; cur=1; } else{ a[i+1]=a[i]+m; cur=1; ans++; } } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...