| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1348830 | mozkun | Monsters (NOI25_monsters) | C++20 | 144 ms | 18108 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF = 1e15;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n, k;
cin >> n >> k;
vector<pair<ll,ll>> a(n+1);
for (ll i = 1; i <= n; i++) {
cin >> a[i].first >> a[i].second;
}
a[0] = {-1, -1};
sort(a.begin(), a.end());
set<ll> s;
set<ll> used;
for (ll i = 0; i < k; i++) {
ll x; cin >> x;
s.insert(x);
}
s.insert(-INF);
s.insert(INF);
ll ans = 0;
for (auto [x, h] : a) {
if (x == -1) continue;
auto r = s.lower_bound(x);
if (*r == x) {
if (!used.count(*r)) {
ans++;
used.insert(*r);
}
continue;
}
auto l = r;
l--;
ll dl = x - *l;
ll dr = *r - x;
ll mn = min(dl, dr);
if (h <= mn) {
ans += h;
continue;
}
if (dl == dr) {
if (used.count(*l)) {
ans += dl;
} else {
ans += dr + 1;
used.insert(*r);
}
}
else if (dl < dr) {
if (used.count(*l)) {
ans += dl;
} else {
ans += dl + 1;
used.insert(*l);
}
}
else {
if (used.count(*r)) {
ans += dr;
} else {
ans += dr + 1;
used.insert(*r);
}
}
}
cout << ans << '\n';
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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
