This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//
// main.cpp
// 1. preserve
//
// Created by KJBS2 on 2014. 12. 24..
// Copyright (c) 2014년 KJBS2. All rights reserved.
//
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
using namespace std;
#define MAX_K 101101
int N, K, D;
int Sort[MAX_K];
int Sum[MAX_K];
int first, second;
bool cmp(int a, int b) {
return a > b;
}
void INPUT() {
scanf("%d%d%d", &N, &K, &D);
int a; scanf("%d", &a); first = a-1;
for(int i=1; i<K; i++) {
int b; scanf("%d", &b);
Sort[i] = b-a-1;
a=b;
}
second = N - a;
sort(Sort+1, Sort+K, cmp);
}
int main() {
INPUT();
for(int i=1; i<K; i++) {
Sum[i] = Sum[i-1] + Sort[i];
}
int nowD = D/2;
if(nowD >= K) nowD = K-1;
int ans = Sum[nowD];
nowD = (D-1)/2; if(nowD >= K) nowD = K-1;
ans = max(ans, Sum[nowD] + first);
nowD = (D-1)/2; if(nowD >= K) nowD = K-1;
ans = max(ans, Sum[nowD] + second);
nowD = (D-2)/2; if(nowD >= K) nowD = K-1;
ans = max(ans, Sum[nowD] + first + second);
printf("%d", ans);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |