# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1090729 | vjudge1 | Safety (NOI18_safety) | C++17 | 239 ms | 21076 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cassert>
#include <iostream>
#include <set>
int main() {
std::cin.tie(NULL)->sync_with_stdio(false);
int n;
long long h;
std::cin >> n >> h;
int m = 0;
long long shift = -h, c = 0;
std::multiset<long long> m_changes[2]; // xpos for each m changes +1
for (int i = 0; i < n; i++) {
long long x;
std::cin >> x;
// shift by h
shift += h;
c -= h * m;
// append to line
m_changes[0].insert(x + shift);
m_changes[1].insert(x - shift);
// normalize
while (true) {
long long x_l = *m_changes[0].rbegin();
long long x_r = *m_changes[1].begin();
# | 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... |
# | 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... |