Submission #13936

#TimeUsernameProblemLanguageResultExecution timeMemory
13936model_code정전 (OJUZ10_blackout)C++98
100 / 100
71 ms3428 KiB
#include<stdio.h> #include<algorithm> using namespace std; struct intv { int x, ad; bool operator< (const intv& c) const { if(x != c.x)return x<c.x; return ad<c.ad; } }ba[300300]; int n, l, t; long long sum; int main(){ int i, a, pv; scanf("%d%d", &n, &l); for(i=0; i<n; i++){ scanf("%d", &a); ba[2*i].x=a-l, ba[2*i].ad=1; ba[2*i+1].x=a+l, ba[2*i+1].ad=-1; } sort(ba, ba+2*n); for(i=0; i<2*n; i++){ if(i>0 && t>=2)sum+=ba[i].x-ba[i-1].x; t+=ba[i].ad; } printf("%lld", sum); 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...