| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 748393 | Sharky | 이상한 기계 (APIO19_strange_device) | C++17 | 655 ms | 84848 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int co[2000010], d[2000010];
void update(int l, int r) {
// cout << "updating: " << l << " " << r << "\n";
d[l]++;
d[r]--;
}
int32_t main() {
ios::sync_with_stdio(0); cin.tie(0);
int n, A, B, ans = 0;
cin >> n >> A >> B;
map<int, bool> mp;
int g = gcd(A, B + 1);
int mul = (A + g - 1) / g;
if (3E18 / mul < B) mul = 3E18;
else mul = (A / g) * B;
// cout << mul << endl;
vector<pair<int, int>> ends;
vector<int> sorted;
for (int i = 0; i < n; i++) {
int l, r;
cin >> l >> r;
if (r - l + 1 >= mul) {
cout << mul << endl;
return 0;
}
l %= mul, r %= mul;
// cout << l << ' ' << r << '\n';
ends.emplace_back(l, r + 1);
sorted.push_back(l);
sorted.push_back(r + 1);
}
sorted.push_back(0);
sorted.push_back(mul);
sort(sorted.begin(), sorted.end());
sorted.erase(unique(sorted.begin(), sorted.end()), sorted.end());
for (int i = 0; i < sorted.size(); i++) co[i+1] = sorted[i];
int mx = 0;
for (int i = 0; i < ends.size(); i++) {
ends[i].first = lower_bound(sorted.begin(), sorted.end(), ends[i].first) - sorted.begin() + 1;
ends[i].second = lower_bound(sorted.begin(), sorted.end(), ends[i].second) - sorted.begin() + 1;
if (ends[i].first > ends[i].second) {
update(ends[i].first, sorted.size());
update(1, ends[i].second);
} else update(ends[i].first, ends[i].second);
}
for (int i = 1; i <= sorted.size(); i++) d[i] += d[i-1];
for (int i = 1; i < sorted.size(); i++) {
// cout << co[i] << ' ' << co[i+1] << ' ' << d[i] << '\n';
if (d[i] > 0) ans += co[i+1] - co[i];
}
cout << ans << '\n';
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... | ||||
