Submission #16620

#TimeUsernameProblemLanguageResultExecution timeMemory
16620eaststar정전 (OJUZ10_blackout)C++14
50 / 100
62 ms2308 KiB
#include <bits/stdc++.h> using namespace std; long long ans; int a[150010]; int main(){ int i,n,l,s,e,t=-1e9; 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...