Submission #12668

# Submission time Handle Problem Language Result Execution time Memory
12668 2014-12-28T09:19:25 Z kipa00 격자 보존하기 (GA9_preserve) C++
0 / 100
32 ms 2372 KB
#include <cstdio>
#include <queue>
using namespace std;

priority_queue<int, vector<int>, greater<int> > put;
int horse[100000];

int main() {
    int start, end, n, k, d;
    int i;
    scanf("%d %d %d", &n, &k, &d);
    for (i=0; i<k; ++i) {
        scanf("%d", &horse[i]);
    }
    start = horse[0] - 1;
    end = n - horse[k - 1];
    for (i=1; i<k; ++i) {
        put.push(horse[i] - horse[i - 1] - 1);
    }
    if (d == 1) printf("%d\n", (start > end) ? start : end);
    else if (d == 2) printf("%d\n", (start + end > put.top()) ? (start + end) : put.top());
    else {
        int nd = d - 2;
        int now = 0, max = -1;
        for (i=0; i<nd/2; ++i) {
            now += put.top();
            put.pop();
        }
        nd %= 2;
        nd += 2;
        if (nd == 3) {
            max = put.top() + start;
            if (max < put.top() + end) {
                max = put.top() + end;
            }
            if (max < start + end) {
                max = start + end;
            }
        } else if (nd == 2) {
            max = start + end;
            if (max < put.top()) {
                max = put.top();
            }
        }
        printf("%d\n", now + max);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1600 KB Output is correct
2 Incorrect 0 ms 1600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 2372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 2372 KB SIGSEGV Segmentation fault
2 Halted 0 ms 0 KB -