Submission #14362

# Submission time Handle Problem Language Result Execution time Memory
14362 2015-05-12T13:02:25 Z Fakeable 정전 (OJUZ10_blackout) C++
0 / 100
48 ms 3216 KB
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int INF = -2100000000;
const int MAX_N = 150500;
int n,l,a[MAX_N],ans,covered = INF;
vector<int> v1,v2;
void input() {
    scanf("%d %d",&n,&l);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    sort(a,a+n);
    return;
}
inline int abs(int x) {
    return x>0?x:-x;
}
inline int calc(int x, int y) {
    if(abs(x-y) >= 2*l) return 0;
    int front, rear;
    if(x<y) {
        rear = x+l;
        front = max(covered, y-l);
        covered = x+l;
    }
    else {
        rear = y+l;
        front = max(covered, x-l);
        covered = y+l;
    }
    return max(rear - front,0);
}
void solve() {
    bool pushzero = true;
    v1.push_back(a[0]);
    for(int i=1;i<n;i++) {
        if(a[i]-a[i-1] < 2*l) {
            if(pushzero) v2.push_back(a[i]), pushzero = false;
            else v1.push_back(a[i]), pushzero = true;
        }
        else v2.push_back(a[i]);
    }
    int iter1 = 0, iter2 = 0;
    while(iter1 < v1.size() || iter2 < v2.size()) {
        //printf("%d %d\n",v1[iter1], v2[iter2]);
        if(iter1 == v1.size()) {
            ans += calc(v1[iter1-1], v2[iter2]);
            iter2 ++;
        }
        else if(iter2 == v2.size()) {
            ans += calc(v1[iter1], v2[iter2-1]);
            iter1 ++;
        }
        else {
            ans += calc(v1[iter1], v2[iter2]);
            if(v1[iter1] < v2[iter2]) iter1 ++;
            else iter2 ++;
        }
    }
    printf("%d\n",ans);
}
int main() {
    input();
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1800 KB Output isn't correct
2 Incorrect 0 ms 1800 KB Output isn't correct
3 Incorrect 0 ms 1800 KB Output isn't correct
4 Correct 0 ms 1800 KB Output is correct
5 Incorrect 0 ms 1800 KB Output isn't correct
6 Runtime error 0 ms 1796 KB SIGSEGV Segmentation fault
7 Incorrect 0 ms 1800 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1800 KB Output is correct
2 Incorrect 0 ms 1800 KB Output isn't correct
3 Correct 0 ms 1800 KB Output is correct
4 Incorrect 0 ms 1800 KB Output isn't 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 Incorrect 44 ms 2828 KB Output isn't correct
2 Incorrect 32 ms 2828 KB Output isn't correct
3 Incorrect 11 ms 2316 KB Output isn't correct
4 Incorrect 25 ms 2828 KB Output isn't correct
5 Incorrect 0 ms 1800 KB Output isn't correct
6 Incorrect 29 ms 2828 KB Output isn't correct
7 Incorrect 46 ms 2828 KB Output isn't correct
8 Incorrect 37 ms 2828 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 2872 KB Output isn't correct
2 Incorrect 33 ms 2448 KB Output isn't correct
3 Correct 38 ms 3216 KB Output is correct
4 Correct 32 ms 3216 KB Output is correct
5 Correct 33 ms 2448 KB Output is correct
6 Correct 33 ms 2448 KB Output is correct
7 Incorrect 32 ms 3088 KB Output isn't correct
8 Incorrect 41 ms 2572 KB Output isn't correct
9 Correct 29 ms 2448 KB Output is correct
10 Incorrect 45 ms 3216 KB Output isn't correct
11 Correct 18 ms 2448 KB Output is correct
12 Correct 11 ms 2080 KB Output is correct
13 Incorrect 40 ms 3216 KB Output isn't correct
14 Incorrect 33 ms 2724 KB Output isn't correct
15 Correct 0 ms 1800 KB Output is correct