답안 #18915

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18915 2016-02-16T12:32:57 Z chan492811 정전 (OJUZ10_blackout) C++
100 / 100
50 ms 1668 KB
#include <cstdio>
#include <algorithm>
using namespace std;

int n,l,ep,sep;
int arr[150010];
long long res;

int main(){
    int i,a,now;
    scanf("%d %d",&n,&l);
    ep=-21e8; sep=-21e8;
    for(i=0;i<n;i++) scanf("%d",&arr[i]); sort(arr,arr+n);
    for(i=0;i<n;i++){
        a=arr[i];
        if(a-l<=ep){
            now=max(sep,a-l);
            res+=max(0,ep-now);
            sep=ep;
        }
        ep=a+l;
    }
    printf("%lld",res);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1668 KB Output is correct
2 Correct 0 ms 1668 KB Output is correct
3 Correct 0 ms 1668 KB Output is correct
4 Correct 0 ms 1668 KB Output is correct
5 Correct 0 ms 1668 KB Output is correct
6 Correct 0 ms 1668 KB Output is correct
7 Correct 0 ms 1668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1668 KB Output is correct
2 Correct 0 ms 1668 KB Output is correct
3 Correct 0 ms 1668 KB Output is correct
4 Correct 0 ms 1668 KB Output is correct
5 Correct 0 ms 1668 KB Output is correct
6 Correct 0 ms 1668 KB Output is correct
7 Correct 0 ms 1668 KB Output is correct
8 Correct 0 ms 1668 KB Output is correct
9 Correct 0 ms 1668 KB Output is correct
10 Correct 0 ms 1668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1668 KB Output is correct
2 Correct 44 ms 1668 KB Output is correct
3 Correct 3 ms 1668 KB Output is correct
4 Correct 25 ms 1668 KB Output is correct
5 Correct 21 ms 1668 KB Output is correct
6 Correct 39 ms 1668 KB Output is correct
7 Correct 18 ms 1668 KB Output is correct
8 Correct 38 ms 1668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1668 KB Output is correct
2 Correct 27 ms 1668 KB Output is correct
3 Correct 0 ms 1668 KB Output is correct
4 Correct 38 ms 1668 KB Output is correct
5 Correct 32 ms 1668 KB Output is correct
6 Correct 41 ms 1668 KB Output is correct
7 Correct 50 ms 1668 KB Output is correct
8 Correct 39 ms 1668 KB Output is correct
9 Correct 26 ms 1668 KB Output is correct
10 Correct 21 ms 1668 KB Output is correct
11 Correct 23 ms 1668 KB Output is correct
12 Correct 12 ms 1668 KB Output is correct
13 Correct 44 ms 1668 KB Output is correct
14 Correct 47 ms 1668 KB Output is correct
15 Correct 38 ms 1668 KB Output is correct