Submission #19103

# Submission time Handle Problem Language Result Execution time Memory
19103 2016-02-18T11:01:32 Z Namnamseo 정전 (OJUZ10_blackout) C++14
100 / 100
69 ms 4012 KB
#include <cstdio>
#include <algorithm>
using namespace std;
typedef pair<int,int> pp;
int p[150010];
pp query[300010];
int n,l;
int main()
{
    scanf("%d%d",&n,&l);
    int i;
    for(i=0;i<n;++i) scanf("%d",p+i);
    sort(p,p+n);
    for(i=0;i<n;++i){
        query[i*2]={p[i]-l,i%2+1};
        query[i*2+1]={p[i]+l,-(i%2+1)};
    }
    sort(query, query+2*n);
    unsigned int ans=0;
    int last=0;
    int on[3]={0,0,0};
    for(i=0;i<2*n;++i){
        pp& cq=query[i];
        if(on[1] && on[2]){
            ans+=((unsigned)(cq.first))-last;
        }
        if(cq.second>0) ++on[cq.second];
        else --on[-cq.second];
        last=cq.first;
    }
    printf("%u\n",ans);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4012 KB Output is correct
2 Correct 0 ms 4012 KB Output is correct
3 Correct 0 ms 4012 KB Output is correct
4 Correct 0 ms 4012 KB Output is correct
5 Correct 0 ms 4012 KB Output is correct
6 Correct 0 ms 4012 KB Output is correct
7 Correct 0 ms 4012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4012 KB Output is correct
2 Correct 0 ms 4012 KB Output is correct
3 Correct 0 ms 4012 KB Output is correct
4 Correct 0 ms 4012 KB Output is correct
5 Correct 0 ms 4012 KB Output is correct
6 Correct 0 ms 4012 KB Output is correct
7 Correct 0 ms 4012 KB Output is correct
8 Correct 0 ms 4012 KB Output is correct
9 Correct 0 ms 4012 KB Output is correct
10 Correct 0 ms 4012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 4012 KB Output is correct
2 Correct 23 ms 4012 KB Output is correct
3 Correct 40 ms 4012 KB Output is correct
4 Correct 54 ms 4012 KB Output is correct
5 Correct 35 ms 4012 KB Output is correct
6 Correct 60 ms 4012 KB Output is correct
7 Correct 0 ms 4012 KB Output is correct
8 Correct 33 ms 4012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 4012 KB Output is correct
2 Correct 55 ms 4012 KB Output is correct
3 Correct 69 ms 4012 KB Output is correct
4 Correct 27 ms 4012 KB Output is correct
5 Correct 50 ms 4012 KB Output is correct
6 Correct 36 ms 4012 KB Output is correct
7 Correct 5 ms 4012 KB Output is correct
8 Correct 58 ms 4012 KB Output is correct
9 Correct 37 ms 4012 KB Output is correct
10 Correct 35 ms 4012 KB Output is correct
11 Correct 57 ms 4012 KB Output is correct
12 Correct 53 ms 4012 KB Output is correct
13 Correct 27 ms 4012 KB Output is correct
14 Correct 29 ms 4012 KB Output is correct
15 Correct 57 ms 4012 KB Output is correct