Submission #348266

# Submission time Handle Problem Language Result Execution time Memory
348266 2021-01-14T12:59:03 Z MrDomino Safety (NOI18_safety) C++14
33 / 100
2000 ms 1656 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define int ll

multiset<int> local_minimum(multiset<int> s, int h) {
  assert((int) s.size() % 2 == 0);
  multiset<int> s2;
  int slope = -(int) s.size() / 2;
  for (auto &x : s) {
    if (slope < 0) {
      s2.insert(x - h);
    }
    if (slope >= 0) {
      s2.insert(x + h);
    }
    slope++;
  }
  return s2;
}


int get(multiset<int> s, int a, int b) {
  int n = (int) s.size();
  vector<int> xs;
  for (auto &it : s) {
    xs.push_back(it);
  }
  for (int i = n - 1; i >= 0; i--) {
    b += xs[i];
    a--;
    if (a == 0) {
      return b;
    }
  }
  assert(0);
}



signed main() {
  ios::sync_with_stdio(0); cin.tie(0);

  multiset<int> s;
  int n, h, x, b = 0;
  cin >> n >> h >> x;
  s.insert(x);
  s.insert(x);
  b = -x;
  b -= h * (n - 1) * n / 2;

  for (int i = 2; i <= n; i++) {
    s = local_minimum(s, h);
    cin >> x;
    s.insert(x);
    s.insert(x);
    auto it = s.end();
    it--;
    b -= x;
  }
  cout << get(s, (int) s.size() / 2, b) << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2076 ms 1388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 35 ms 640 KB Output is correct
14 Correct 29 ms 492 KB Output is correct
15 Correct 29 ms 492 KB Output is correct
16 Correct 32 ms 492 KB Output is correct
17 Correct 25 ms 492 KB Output is correct
18 Correct 17 ms 492 KB Output is correct
19 Correct 29 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 35 ms 640 KB Output is correct
14 Correct 29 ms 492 KB Output is correct
15 Correct 29 ms 492 KB Output is correct
16 Correct 32 ms 492 KB Output is correct
17 Correct 25 ms 492 KB Output is correct
18 Correct 17 ms 492 KB Output is correct
19 Correct 29 ms 492 KB Output is correct
20 Correct 28 ms 492 KB Output is correct
21 Correct 33 ms 488 KB Output is correct
22 Correct 22 ms 492 KB Output is correct
23 Correct 21 ms 492 KB Output is correct
24 Correct 27 ms 492 KB Output is correct
25 Correct 25 ms 492 KB Output is correct
26 Correct 32 ms 492 KB Output is correct
27 Correct 28 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 35 ms 640 KB Output is correct
14 Correct 29 ms 492 KB Output is correct
15 Correct 29 ms 492 KB Output is correct
16 Correct 32 ms 492 KB Output is correct
17 Correct 25 ms 492 KB Output is correct
18 Correct 17 ms 492 KB Output is correct
19 Correct 29 ms 492 KB Output is correct
20 Correct 28 ms 492 KB Output is correct
21 Correct 33 ms 488 KB Output is correct
22 Correct 22 ms 492 KB Output is correct
23 Correct 21 ms 492 KB Output is correct
24 Correct 27 ms 492 KB Output is correct
25 Correct 25 ms 492 KB Output is correct
26 Correct 32 ms 492 KB Output is correct
27 Correct 28 ms 620 KB Output is correct
28 Execution timed out 2058 ms 1656 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 35 ms 640 KB Output is correct
20 Correct 29 ms 492 KB Output is correct
21 Correct 29 ms 492 KB Output is correct
22 Correct 32 ms 492 KB Output is correct
23 Correct 25 ms 492 KB Output is correct
24 Correct 17 ms 492 KB Output is correct
25 Correct 29 ms 492 KB Output is correct
26 Correct 28 ms 492 KB Output is correct
27 Correct 33 ms 488 KB Output is correct
28 Correct 22 ms 492 KB Output is correct
29 Correct 21 ms 492 KB Output is correct
30 Correct 27 ms 492 KB Output is correct
31 Correct 25 ms 492 KB Output is correct
32 Correct 32 ms 492 KB Output is correct
33 Correct 28 ms 620 KB Output is correct
34 Execution timed out 2058 ms 1656 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Execution timed out 2076 ms 1388 KB Time limit exceeded
20 Halted 0 ms 0 KB -