Submission #14717

# Submission time Handle Problem Language Result Execution time Memory
14717 2015-06-13T02:22:09 Z baneling100 정전 (OJUZ10_blackout) C++
100 / 100
51 ms 2256 KB
#include <stdio.h>
#include <algorithm>
#define N_MAX 150000

using namespace std;

long long N, L, Light[N_MAX+1], Res;

int main(void) {

    int i;

    scanf("%lld %lld",&N,&L);
    for(i=1 ; i<=N ; i++) scanf("%lld",&Light[i]);
    sort(Light+1,Light+N+1);
    if(N==1) {
        printf("0");
        return 0;
    }
    if(Light[1]-Light[2]+2*L>0) Res=Light[1]-Light[2]+2*L;
    for(i=3 ; i<=N ; i++) {
        if(Light[i-2]+L<Light[i]-L) {
            if(Light[i-1]-Light[i]+2*L>0) Res+=Light[i-1]-Light[i]+2*L;
        }
        else Res+=Light[i-1]-Light[i-2];
    }
    printf("%lld",Res);

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2256 KB Output is correct
2 Correct 0 ms 2256 KB Output is correct
3 Correct 0 ms 2256 KB Output is correct
4 Correct 0 ms 2256 KB Output is correct
5 Correct 0 ms 2256 KB Output is correct
6 Correct 0 ms 2256 KB Output is correct
7 Correct 0 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2256 KB Output is correct
2 Correct 0 ms 2256 KB Output is correct
3 Correct 0 ms 2256 KB Output is correct
4 Correct 0 ms 2256 KB Output is correct
5 Correct 0 ms 2256 KB Output is correct
6 Correct 0 ms 2256 KB Output is correct
7 Correct 0 ms 2256 KB Output is correct
8 Correct 0 ms 2256 KB Output is correct
9 Correct 0 ms 2256 KB Output is correct
10 Correct 0 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2256 KB Output is correct
2 Correct 0 ms 2256 KB Output is correct
3 Correct 30 ms 2256 KB Output is correct
4 Correct 50 ms 2256 KB Output is correct
5 Correct 38 ms 2256 KB Output is correct
6 Correct 22 ms 2256 KB Output is correct
7 Correct 37 ms 2256 KB Output is correct
8 Correct 19 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 2256 KB Output is correct
2 Correct 31 ms 2256 KB Output is correct
3 Correct 38 ms 2256 KB Output is correct
4 Correct 34 ms 2256 KB Output is correct
5 Correct 45 ms 2256 KB Output is correct
6 Correct 37 ms 2256 KB Output is correct
7 Correct 37 ms 2256 KB Output is correct
8 Correct 31 ms 2256 KB Output is correct
9 Correct 34 ms 2256 KB Output is correct
10 Correct 0 ms 2256 KB Output is correct
11 Correct 49 ms 2256 KB Output is correct
12 Correct 20 ms 2256 KB Output is correct
13 Correct 26 ms 2256 KB Output is correct
14 Correct 31 ms 2256 KB Output is correct
15 Correct 51 ms 2256 KB Output is correct