Submission #18915

#TimeUsernameProblemLanguageResultExecution timeMemory
18915chan492811정전 (OJUZ10_blackout)C++98
100 / 100
50 ms1668 KiB
#include <cstdio> #include <algorithm> using namespace std; int n,l,ep,sep; int arr[150010]; long long res; int main(){ int i,a,now; scanf("%d %d",&n,&l); ep=-21e8; sep=-21e8; for(i=0;i<n;i++) scanf("%d",&arr[i]); sort(arr,arr+n); for(i=0;i<n;i++){ a=arr[i]; if(a-l<=ep){ now=max(sep,a-l); res+=max(0,ep-now); sep=ep; } ep=a+l; } printf("%lld",res); 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...