답안 #14363

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14363 2015-05-12T13:10:01 Z Fakeable 정전 (OJUZ10_blackout) C++
50 / 100
52 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,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 += max(0, rear-front);
        covered = rear;
    }
    printf("%d\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 Incorrect 0 ms 1668 KB Output isn't 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 20 ms 1668 KB Output is correct
2 Correct 38 ms 1668 KB Output is correct
3 Correct 27 ms 1668 KB Output is correct
4 Correct 0 ms 1668 KB Output is correct
5 Correct 26 ms 1668 KB Output is correct
6 Correct 31 ms 1668 KB Output is correct
7 Correct 29 ms 1668 KB Output is correct
8 Correct 51 ms 1668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1668 KB Output is correct
2 Correct 52 ms 1668 KB Output is correct
3 Correct 45 ms 1668 KB Output is correct
4 Correct 3 ms 1668 KB Output is correct
5 Correct 43 ms 1668 KB Output is correct
6 Correct 35 ms 1668 KB Output is correct
7 Correct 32 ms 1668 KB Output is correct
8 Correct 13 ms 1668 KB Output is correct
9 Correct 40 ms 1668 KB Output is correct
10 Correct 46 ms 1668 KB Output is correct
11 Correct 20 ms 1668 KB Output is correct
12 Correct 42 ms 1668 KB Output is correct
13 Incorrect 31 ms 1668 KB Output isn't correct
14 Correct 18 ms 1668 KB Output is correct
15 Correct 34 ms 1668 KB Output is correct