1 solutions
-
0
C++ :
#include<bits/stdc++.h> using namespace std; long long n,t,x,a1,b1,a2,b2,ans; int main() { // freopen("590.in","r",stdin); // freopen("590.out","w",stdout); cin>>n>>t>>x; a1=x,b1=x+t-1; ans=b1-a1+1; for(int i=1;i<n;i++) { cin>>x; a2=x,b2=x+t-1; if(a2>b1) ans+=t; else ans+=t-(b1-a2+1); a1=a2,b1=b2; } cout<<ans; return 0; }
- 1
Information
- ID
- 962
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By