Submission #14157

# Submission time Handle Problem Language Result Execution time Memory
14157 2015-05-02T15:35:19 Z dohyun0324 정전 (OJUZ10_blackout) C++
100 / 100
69 ms 5184 KB
#include<stdio.h>
#include<algorithm>
using namespace std;
int w,n,l,a[150010],ch[300010];
long long dap;
struct data
{
    int pos,sw;
    bool operator<(const data&r)const
    {
        return pos<r.pos;
    }
}arr[300010];
int main()
{
    int i;
    scanf("%d %d",&n,&l);
    for(i=1;i<=n;i++) scanf("%d",&a[i]);
    for(i=1;i<=n;i++)
    {
        w++; arr[w].pos=a[i]-l; arr[w].sw=1;
        w++; arr[w].pos=a[i]+l; arr[w].sw=-1;
    }
    sort(arr+1,arr+w+1);
    for(i=1;i<=w;i++)
    {
        ch[i]=ch[i-1]+arr[i].sw;
    }
    for(i=1;i<=w;i++)
    {
        if(ch[i]>=2) dap+=arr[i+1].pos-arr[i].pos;
    }
    printf("%lld",dap);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5184 KB Output is correct
2 Correct 0 ms 5184 KB Output is correct
3 Correct 0 ms 5184 KB Output is correct
4 Correct 0 ms 5184 KB Output is correct
5 Correct 0 ms 5184 KB Output is correct
6 Correct 0 ms 5184 KB Output is correct
7 Correct 0 ms 5184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5184 KB Output is correct
2 Correct 0 ms 5184 KB Output is correct
3 Correct 0 ms 5184 KB Output is correct
4 Correct 0 ms 5184 KB Output is correct
5 Correct 0 ms 5184 KB Output is correct
6 Correct 0 ms 5184 KB Output is correct
7 Correct 0 ms 5184 KB Output is correct
8 Correct 0 ms 5184 KB Output is correct
9 Correct 0 ms 5184 KB Output is correct
10 Correct 0 ms 5184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 5184 KB Output is correct
2 Correct 64 ms 5184 KB Output is correct
3 Correct 65 ms 5184 KB Output is correct
4 Correct 43 ms 5184 KB Output is correct
5 Correct 60 ms 5184 KB Output is correct
6 Correct 4 ms 5184 KB Output is correct
7 Correct 41 ms 5184 KB Output is correct
8 Correct 41 ms 5184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 5184 KB Output is correct
2 Correct 47 ms 5184 KB Output is correct
3 Correct 38 ms 5184 KB Output is correct
4 Correct 58 ms 5184 KB Output is correct
5 Correct 37 ms 5184 KB Output is correct
6 Correct 31 ms 5184 KB Output is correct
7 Correct 26 ms 5184 KB Output is correct
8 Correct 59 ms 5184 KB Output is correct
9 Correct 39 ms 5184 KB Output is correct
10 Correct 38 ms 5184 KB Output is correct
11 Correct 37 ms 5184 KB Output is correct
12 Correct 55 ms 5184 KB Output is correct
13 Correct 68 ms 5184 KB Output is correct
14 Correct 2 ms 5184 KB Output is correct
15 Correct 61 ms 5184 KB Output is correct