답안 #13937

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
13937 2015-04-24T05:23:49 Z model_code 정전 (OJUZ10_blackout) C++
100 / 100
73 ms 3428 KB
#include<stdio.h>
#include<algorithm>
using namespace std;
 
struct intv {
    int x, ad;
    bool operator< (const intv& c) const {
        if(x != c.x)return x<c.x;
        return ad<c.ad;
    }
}ba[300300];
 
int n, l, t;
long long sum;
 
int main(){
    int i, a, pv;
    scanf("%d%d", &n, &l);
    for(i=0; i<n; i++){
        scanf("%d", &a);
        ba[2*i].x=a-l, ba[2*i].ad=1;
        ba[2*i+1].x=a+l, ba[2*i+1].ad=-1;
    }
    sort(ba, ba+2*n);
    for(i=0; i<2*n; i++){
        if(i>0 && t>=2)sum+=ba[i].x-ba[i-1].x;
        t+=ba[i].ad;
    }
    printf("%lld", sum);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3428 KB Output is correct
2 Correct 0 ms 3428 KB Output is correct
3 Correct 0 ms 3428 KB Output is correct
4 Correct 0 ms 3428 KB Output is correct
5 Correct 0 ms 3428 KB Output is correct
6 Correct 0 ms 3428 KB Output is correct
7 Correct 0 ms 3428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3428 KB Output is correct
2 Correct 0 ms 3428 KB Output is correct
3 Correct 0 ms 3428 KB Output is correct
4 Correct 0 ms 3428 KB Output is correct
5 Correct 0 ms 3428 KB Output is correct
6 Correct 0 ms 3428 KB Output is correct
7 Correct 0 ms 3428 KB Output is correct
8 Correct 0 ms 3428 KB Output is correct
9 Correct 0 ms 3428 KB Output is correct
10 Correct 0 ms 3428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 3428 KB Output is correct
2 Correct 37 ms 3428 KB Output is correct
3 Correct 39 ms 3428 KB Output is correct
4 Correct 55 ms 3428 KB Output is correct
5 Correct 39 ms 3428 KB Output is correct
6 Correct 60 ms 3428 KB Output is correct
7 Correct 61 ms 3428 KB Output is correct
8 Correct 4 ms 3428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3428 KB Output is correct
2 Correct 65 ms 3428 KB Output is correct
3 Correct 73 ms 3428 KB Output is correct
4 Correct 42 ms 3428 KB Output is correct
5 Correct 64 ms 3428 KB Output is correct
6 Correct 38 ms 3428 KB Output is correct
7 Correct 36 ms 3428 KB Output is correct
8 Correct 46 ms 3428 KB Output is correct
9 Correct 16 ms 3428 KB Output is correct
10 Correct 71 ms 3428 KB Output is correct
11 Correct 44 ms 3428 KB Output is correct
12 Correct 73 ms 3428 KB Output is correct
13 Correct 41 ms 3428 KB Output is correct
14 Correct 57 ms 3428 KB Output is correct
15 Correct 43 ms 3428 KB Output is correct