Submission #16622

#TimeUsernameProblemLanguageResultExecution timeMemory
16622eaststar정전 (OJUZ10_blackout)C++14
100 / 100
65 ms2308 KiB
#include <bits/stdc++.h> using namespace std; int a[150010]; long long ans; int main(){ int i,n,l,s,e,t=-2e9; scanf("%d%d",&n,&l); for(i=0;i<n;++i)scanf("%d",a+i); sort(a,a+n); for(i=1;i<n;++i){ s=a[i]-l,e=a[i-1]+l; if(s<e)ans+=e-max(s,t),t=e; } printf("%lld",ans); 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...