Submission #20172

#TimeUsernameProblemLanguageResultExecution timeMemory
20172suhgyuho_william정전 (OJUZ10_blackout)C++98
100 / 100
50 ms2256 KiB
#include <stdio.h> #include <algorithm> using namespace std; #define lld long long int N; lld a[150010],L; lld ans; int main(){ int i; lld e,s; //freopen("input.txt","r",stdin); scanf("%d %lld",&N,&L); for(i=1; i<=N; i++) scanf("%lld",&a[i]); sort(a+1,a+N+1); for(i=2; i<=N; i++){ e = a[i-1]+L; s = a[i]-L; if(e <= s) continue; if(i > 2) s = max(s,a[i-2]+L); ans += (e-s); } 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...