-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcdd.cpp
More file actions
46 lines (43 loc) · 698 Bytes
/
cdd.cpp
File metadata and controls
46 lines (43 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long int n,l,r;
scanf("%lld%lld%lld",&n,&l,&r);
long long int arr[n],count=0,a,b,tar[r+1]={0};
for(long long int i=0;i<n;i++)
scanf("%lld",&arr[i]);
sort(arr,arr+n);
vector<pair<int,int> >v(n-1);
for(long long int i=0;i<n-1;i++)
{
pair<int,int>p;
p=make_pair(arr[i+1]-arr[i],arr[i+1]+arr[i]);
v[i]=p;
}
a=l;
b=r;
for(long long int i=0;i<n-1;i++)
{
/*l=a;
r=b;
while(l<=r)
{
if(v[i].first<l && l<v[i].second)
{
//cout<<l<<endl;
tar[l]=1;
l++;
}
else
l++;
}*/
}
for(long long int i=a;i<r+1;i++)
{
if(tar[i]==1)
count++;
}
printf("%lld\n",count);
return 0;
}