# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
348265 |
2021-01-14T12:57:01 Z |
MrDomino |
Safety (NOI18_safety) |
C++14 |
|
2000 ms |
1476 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;
for (int i = 2; i <= n; i++) {
s = local_minimum(s, h);
cin >> x;
b -= (i - 1) * h; /// I have no clue why this happens lol
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 |
0 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 |
492 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 |
0 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2017 ms |
1476 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 |
0 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 |
31 ms |
492 KB |
Output is correct |
14 |
Correct |
30 ms |
748 KB |
Output is correct |
15 |
Correct |
29 ms |
492 KB |
Output is correct |
16 |
Correct |
31 ms |
492 KB |
Output is correct |
17 |
Correct |
24 ms |
492 KB |
Output is correct |
18 |
Correct |
17 ms |
492 KB |
Output is correct |
19 |
Correct |
28 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 |
0 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 |
31 ms |
492 KB |
Output is correct |
14 |
Correct |
30 ms |
748 KB |
Output is correct |
15 |
Correct |
29 ms |
492 KB |
Output is correct |
16 |
Correct |
31 ms |
492 KB |
Output is correct |
17 |
Correct |
24 ms |
492 KB |
Output is correct |
18 |
Correct |
17 ms |
492 KB |
Output is correct |
19 |
Correct |
28 ms |
492 KB |
Output is correct |
20 |
Correct |
27 ms |
492 KB |
Output is correct |
21 |
Correct |
31 ms |
472 KB |
Output is correct |
22 |
Correct |
22 ms |
492 KB |
Output is correct |
23 |
Correct |
18 ms |
492 KB |
Output is correct |
24 |
Correct |
27 ms |
492 KB |
Output is correct |
25 |
Correct |
19 ms |
492 KB |
Output is correct |
26 |
Correct |
31 ms |
492 KB |
Output is correct |
27 |
Correct |
27 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 |
0 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 |
31 ms |
492 KB |
Output is correct |
14 |
Correct |
30 ms |
748 KB |
Output is correct |
15 |
Correct |
29 ms |
492 KB |
Output is correct |
16 |
Correct |
31 ms |
492 KB |
Output is correct |
17 |
Correct |
24 ms |
492 KB |
Output is correct |
18 |
Correct |
17 ms |
492 KB |
Output is correct |
19 |
Correct |
28 ms |
492 KB |
Output is correct |
20 |
Correct |
27 ms |
492 KB |
Output is correct |
21 |
Correct |
31 ms |
472 KB |
Output is correct |
22 |
Correct |
22 ms |
492 KB |
Output is correct |
23 |
Correct |
18 ms |
492 KB |
Output is correct |
24 |
Correct |
27 ms |
492 KB |
Output is correct |
25 |
Correct |
19 ms |
492 KB |
Output is correct |
26 |
Correct |
31 ms |
492 KB |
Output is correct |
27 |
Correct |
27 ms |
492 KB |
Output is correct |
28 |
Execution timed out |
2085 ms |
1296 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 |
0 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 |
492 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 |
0 ms |
364 KB |
Output is correct |
19 |
Correct |
31 ms |
492 KB |
Output is correct |
20 |
Correct |
30 ms |
748 KB |
Output is correct |
21 |
Correct |
29 ms |
492 KB |
Output is correct |
22 |
Correct |
31 ms |
492 KB |
Output is correct |
23 |
Correct |
24 ms |
492 KB |
Output is correct |
24 |
Correct |
17 ms |
492 KB |
Output is correct |
25 |
Correct |
28 ms |
492 KB |
Output is correct |
26 |
Correct |
27 ms |
492 KB |
Output is correct |
27 |
Correct |
31 ms |
472 KB |
Output is correct |
28 |
Correct |
22 ms |
492 KB |
Output is correct |
29 |
Correct |
18 ms |
492 KB |
Output is correct |
30 |
Correct |
27 ms |
492 KB |
Output is correct |
31 |
Correct |
19 ms |
492 KB |
Output is correct |
32 |
Correct |
31 ms |
492 KB |
Output is correct |
33 |
Correct |
27 ms |
492 KB |
Output is correct |
34 |
Execution timed out |
2085 ms |
1296 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 |
0 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 |
492 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 |
0 ms |
364 KB |
Output is correct |
19 |
Execution timed out |
2017 ms |
1476 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |