Submission #14062

# Submission time Handle Problem Language Result Execution time Memory
14062 2015-04-26T02:36:29 Z kipa00 정전 (OJUZ10_blackout) C++
100 / 100
55 ms 2384 KB
#include <cstdio>
#include <algorithm>
using namespace std;

int location[150000];
int L;

int dist(int a, int b) {
    int t = 2 * L - (b - a);
    return t > 0 ? t : 0;
}

int main() {
    int N, i;
    long long int l = 0;
    scanf("%d%d", &N, &L);
    for (i=0; i<N; ++i) {
        scanf("%d", location+i);
    }
    stable_sort(location, location+N);
    for (i=1; i<N; ++i) {
        l += dist(location[i - 1], location[i]);
    }
    for (i=2; i<N; ++i) {
        l -= dist(location[i - 2], location[i]);
    }
    printf("%lld\n", l);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1800 KB Output is correct
2 Correct 0 ms 1800 KB Output is correct
3 Correct 0 ms 1800 KB Output is correct
4 Correct 0 ms 1800 KB Output is correct
5 Correct 0 ms 1800 KB Output is correct
6 Correct 0 ms 1800 KB Output is correct
7 Correct 0 ms 1800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1800 KB Output is correct
2 Correct 0 ms 1800 KB Output is correct
3 Correct 0 ms 1800 KB Output is correct
4 Correct 0 ms 1800 KB Output is correct
5 Correct 0 ms 1800 KB Output is correct
6 Correct 0 ms 1800 KB Output is correct
7 Correct 0 ms 1800 KB Output is correct
8 Correct 0 ms 1800 KB Output is correct
9 Correct 0 ms 1800 KB Output is correct
10 Correct 0 ms 1800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2188 KB Output is correct
2 Correct 41 ms 2384 KB Output is correct
3 Correct 0 ms 1800 KB Output is correct
4 Correct 29 ms 2188 KB Output is correct
5 Correct 53 ms 2384 KB Output is correct
6 Correct 17 ms 2164 KB Output is correct
7 Correct 51 ms 2384 KB Output is correct
8 Correct 12 ms 2032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 2384 KB Output is correct
2 Correct 0 ms 1800 KB Output is correct
3 Correct 54 ms 2384 KB Output is correct
4 Correct 35 ms 2188 KB Output is correct
5 Correct 27 ms 2100 KB Output is correct
6 Correct 34 ms 2180 KB Output is correct
7 Correct 49 ms 2384 KB Output is correct
8 Correct 35 ms 2188 KB Output is correct
9 Correct 55 ms 2384 KB Output is correct
10 Correct 21 ms 2032 KB Output is correct
11 Correct 53 ms 2384 KB Output is correct
12 Correct 33 ms 2164 KB Output is correct
13 Correct 30 ms 2188 KB Output is correct
14 Correct 41 ms 2384 KB Output is correct
15 Correct 41 ms 2384 KB Output is correct