# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20242 | jjwdi0 | 정전 (OJUZ10_blackout) | C++98 | 44 ms | 24 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 <stdio.h>
#include <algorithm>
#define INF -1234567891
typedef long long ll;
using namespace std;
int a[150005], l;
int n, i, left=INF, right=INF, t1, t2;
ll ans;
int f(int x)
{
return x>0?x:0;
}
main()
{
scanf("%d%d", &n, &l);
for(i=0; i<n; i++)scanf("%d", a+i);
sort(a, a+n);
for(i=1; i<n; i++)
{
if(a[i]-a[i-1]>=2*l)continue;
t1=a[i]-l;t2=a[i-1]+l;
// printf("%d %d\n", t2-t1, f(right-t1));
ans+=(ll)(t2-t1)-(ll)f(right-t1);
left=t1;right=t2;
// printf("%lld\n", ans);
}
printf("%lld", ans);
}
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... |