# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
983357 | michified | Sails (IOI07_sails) | C++17 | 40 ms | 5716 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
struct mast_t {
ll cnt, h;
};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
ll n, i, l, r, tmp;
cin >> n;
vector<mast_t> masts(n);
for (i = 0; i < n; i++) cin >> masts[i].h >> masts[i].cnt;
sort(masts.begin(), masts.end(), [](const mast_t& one, const mast_t& two){return one.h < two.h;});
map<ll, ll> histo;
mast_t mast;
histo[0]++;
histo[masts[0].cnt]--;
for (i = 1; i < n; i++) {
mast = masts[i];
l = mast.h - mast.cnt;
r = mast.h;
histo[r]--;
if (histo.find(l) != histo.end()) {
histo[l]++;
if (histo[l] == 0) histo.erase(l);
continue;
}
auto lo = prev(histo.lower_bound(l)), hi = histo.upper_bound(l);
lo -> second++;
histo[lo -> first - l + hi -> first]--;
if (lo -> second == 0) histo.erase(lo);
hi -> second++;
if (hi -> second == 0) histo.erase(hi);
}
auto cur = histo.begin();
ll ans = 0, count = cur -> second;
while (count > 0) {
ans += count * (count - 1) * (next(cur) -> first - cur -> first);
count += next(cur) -> second;
cur = next(cur);
}
cout << ans / 2;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |