답안 #14364

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14364 2015-05-12T13:15:01 Z Fakeable 정전 (OJUZ10_blackout) C++
100 / 100
51 ms 1668 KB
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAX_N = 150050;
const int INF = -2100000000;
int n,k,a[MAX_N],covered = INF;
long long ans;
int front, rear;
void input() {
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    sort(a,a+n);
}
void solve() {
    for(int i=0;i<n-1;i++) {
        if(a[i+1]-a[i] >= 2*k) continue;
        rear = a[i] + k;
        if(rear <= covered) continue;
        front = max(a[i+1] - k, covered);
        ans += (long long)max(0, rear-front);
        covered = rear;
    }
    printf("%lld\n",ans);
}
int main() {
    input();
    solve();
}
# 결과 실행 시간 메모리 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 27 ms 1668 KB Output is correct
2 Correct 0 ms 1668 KB Output is correct
3 Correct 48 ms 1668 KB Output is correct
4 Correct 32 ms 1668 KB Output is correct
5 Correct 43 ms 1668 KB Output is correct
6 Correct 19 ms 1668 KB Output is correct
7 Correct 42 ms 1668 KB Output is correct
8 Correct 19 ms 1668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 1668 KB Output is correct
2 Correct 35 ms 1668 KB Output is correct
3 Correct 42 ms 1668 KB Output is correct
4 Correct 31 ms 1668 KB Output is correct
5 Correct 0 ms 1668 KB Output is correct
6 Correct 31 ms 1668 KB Output is correct
7 Correct 38 ms 1668 KB Output is correct
8 Correct 42 ms 1668 KB Output is correct
9 Correct 51 ms 1668 KB Output is correct
10 Correct 49 ms 1668 KB Output is correct
11 Correct 33 ms 1668 KB Output is correct
12 Correct 27 ms 1668 KB Output is correct
13 Correct 19 ms 1668 KB Output is correct
14 Correct 32 ms 1668 KB Output is correct
15 Correct 25 ms 1668 KB Output is correct