Submission #12090

# Submission time Handle Problem Language Result Execution time Memory
12090 2014-12-21T03:44:09 Z ainu7 격자 보존하기 (GA9_preserve) C++
100 / 100
76 ms 2844 KB
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

int first(vector<int>& dist, int num) {
  num = min((int)dist.size(), num);
  int res = 0;
  for (int i=0; i<num; i++) res += dist[i];
  return res;
}

int main()
{
  int n, k, d;
  cin >> n >> k >> d;
  vector<int> horse(k);
  for (int i=0; i<k; i++) cin >> horse[i];
  sort(horse.begin(), horse.end());

  int ll = horse[0] - 1;
  int rr = n - horse[k-1];

  vector<int> dist;
  for (int i=0; i<k-1; i++) dist.push_back(horse[i+1]-horse[i]-1);
  sort(dist.rbegin(), dist.rend());

  int res = 0;
  res = max(res, first(dist, d/2));
  res = max(res, max(ll, rr) + first(dist, (d-1)/2));
  if (d >= 2) res = max(res, ll + rr + first(dist, d/2-1));
  cout << res << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1680 KB Output is correct
2 Correct 0 ms 1680 KB Output is correct
3 Correct 0 ms 1680 KB Output is correct
4 Correct 0 ms 1680 KB Output is correct
5 Correct 0 ms 1680 KB Output is correct
6 Correct 0 ms 1680 KB Output is correct
7 Correct 0 ms 1680 KB Output is correct
8 Correct 0 ms 1680 KB Output is correct
9 Correct 0 ms 1680 KB Output is correct
10 Correct 0 ms 1680 KB Output is correct
11 Correct 0 ms 1680 KB Output is correct
12 Correct 0 ms 1680 KB Output is correct
13 Correct 0 ms 1680 KB Output is correct
14 Correct 0 ms 1680 KB Output is correct
15 Correct 0 ms 1680 KB Output is correct
16 Correct 0 ms 1680 KB Output is correct
17 Correct 0 ms 1680 KB Output is correct
18 Correct 0 ms 1680 KB Output is correct
19 Correct 0 ms 1680 KB Output is correct
20 Correct 0 ms 1680 KB Output is correct
21 Correct 0 ms 1680 KB Output is correct
22 Correct 0 ms 1680 KB Output is correct
23 Correct 0 ms 1680 KB Output is correct
24 Correct 0 ms 1680 KB Output is correct
25 Correct 0 ms 1680 KB Output is correct
26 Correct 0 ms 1680 KB Output is correct
27 Correct 0 ms 1680 KB Output is correct
28 Correct 0 ms 1680 KB Output is correct
29 Correct 0 ms 1680 KB Output is correct
30 Correct 0 ms 1680 KB Output is correct
31 Correct 0 ms 1680 KB Output is correct
32 Correct 0 ms 1680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1680 KB Output is correct
2 Correct 0 ms 1680 KB Output is correct
3 Correct 0 ms 1680 KB Output is correct
4 Correct 0 ms 1680 KB Output is correct
5 Correct 0 ms 1680 KB Output is correct
6 Correct 0 ms 1680 KB Output is correct
7 Correct 0 ms 1680 KB Output is correct
8 Correct 0 ms 1680 KB Output is correct
9 Correct 0 ms 1680 KB Output is correct
10 Correct 0 ms 1680 KB Output is correct
11 Correct 0 ms 1680 KB Output is correct
12 Correct 0 ms 1680 KB Output is correct
13 Correct 0 ms 1680 KB Output is correct
14 Correct 0 ms 1680 KB Output is correct
15 Correct 0 ms 1680 KB Output is correct
16 Correct 0 ms 1680 KB Output is correct
17 Correct 0 ms 1680 KB Output is correct
18 Correct 0 ms 1680 KB Output is correct
19 Correct 0 ms 1680 KB Output is correct
20 Correct 0 ms 1680 KB Output is correct
21 Correct 0 ms 1680 KB Output is correct
22 Correct 0 ms 1680 KB Output is correct
23 Correct 0 ms 1680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1680 KB Output is correct
2 Correct 0 ms 1680 KB Output is correct
3 Correct 0 ms 1680 KB Output is correct
4 Correct 0 ms 1680 KB Output is correct
5 Correct 0 ms 1680 KB Output is correct
6 Correct 0 ms 1680 KB Output is correct
7 Correct 0 ms 1680 KB Output is correct
8 Correct 0 ms 1680 KB Output is correct
9 Correct 0 ms 1680 KB Output is correct
10 Correct 0 ms 1680 KB Output is correct
11 Correct 0 ms 1680 KB Output is correct
12 Correct 0 ms 1680 KB Output is correct
13 Correct 0 ms 1680 KB Output is correct
14 Correct 0 ms 1680 KB Output is correct
15 Correct 0 ms 1680 KB Output is correct
16 Correct 0 ms 1680 KB Output is correct
17 Correct 0 ms 1680 KB Output is correct
18 Correct 0 ms 1680 KB Output is correct
19 Correct 0 ms 1680 KB Output is correct
20 Correct 0 ms 1680 KB Output is correct
21 Correct 0 ms 1680 KB Output is correct
22 Correct 0 ms 1680 KB Output is correct
23 Correct 0 ms 1680 KB Output is correct
24 Correct 0 ms 1680 KB Output is correct
25 Correct 0 ms 1680 KB Output is correct
26 Correct 0 ms 1680 KB Output is correct
27 Correct 0 ms 1680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 2844 KB Output is correct
2 Correct 76 ms 2844 KB Output is correct
3 Correct 76 ms 2844 KB Output is correct
4 Correct 72 ms 2844 KB Output is correct
5 Correct 76 ms 2844 KB Output is correct
6 Correct 72 ms 2844 KB Output is correct
7 Correct 72 ms 2844 KB Output is correct
8 Correct 68 ms 2844 KB Output is correct
9 Correct 36 ms 2264 KB Output is correct
10 Correct 20 ms 1940 KB Output is correct
11 Correct 68 ms 2828 KB Output is correct
12 Correct 68 ms 2836 KB Output is correct
13 Correct 68 ms 2828 KB Output is correct
14 Correct 68 ms 2836 KB Output is correct
15 Correct 72 ms 2840 KB Output is correct
16 Correct 68 ms 2840 KB Output is correct
17 Correct 68 ms 2832 KB Output is correct
18 Correct 68 ms 2828 KB Output is correct
19 Correct 72 ms 2828 KB Output is correct
20 Correct 0 ms 1680 KB Output is correct
21 Correct 0 ms 1680 KB Output is correct
22 Correct 64 ms 2824 KB Output is correct
23 Correct 72 ms 2836 KB Output is correct
24 Correct 60 ms 2836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 2844 KB Output is correct
2 Correct 68 ms 2844 KB Output is correct
3 Correct 76 ms 2844 KB Output is correct
4 Correct 72 ms 2844 KB Output is correct
5 Correct 72 ms 2844 KB Output is correct
6 Correct 72 ms 2844 KB Output is correct
7 Correct 64 ms 2844 KB Output is correct
8 Correct 72 ms 2844 KB Output is correct
9 Correct 32 ms 2264 KB Output is correct
10 Correct 20 ms 1940 KB Output is correct
11 Correct 52 ms 2728 KB Output is correct
12 Correct 44 ms 2756 KB Output is correct
13 Correct 60 ms 2764 KB Output is correct
14 Correct 56 ms 2760 KB Output is correct
15 Correct 44 ms 2768 KB Output is correct
16 Correct 52 ms 2792 KB Output is correct
17 Correct 60 ms 2820 KB Output is correct
18 Correct 52 ms 2804 KB Output is correct
19 Correct 52 ms 2752 KB Output is correct
20 Correct 64 ms 2812 KB Output is correct