# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91878 | tjrwodnjs999 | 정전 (OJUZ10_blackout) | C++11 | 54 ms | 6776 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
long long n,m,s,sum,l,cnt;
pair<long long,long long> arr[300005];
int main()
{
scanf("%lld%lld",&n,&m);
for(int i=0;i<n;i++){
scanf("%lld",&s);
arr[i*2]={s-m,-1};
arr[i*2+1]={s+m,1};
}
sort(arr,arr+2*n);
for(int i=0;i<n*2;i++){
if(arr[i].y==-1){
if(sum==1) l=arr[i].x;
sum++;
}
else{
if(sum==2) cnt+=arr[i].x-l;
sum--;
}
}
printf("%lld",cnt);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |