| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 335099 | CSQ31 | 이상한 기계 (APIO19_strange_device) | C++14 | 831 ms | 76908 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 4e6;
int n, m, tot, sum[maxn + 3];
ll A, B, C, l, r, temp[maxn + 3];
pair<ll, ll> sect[maxn + 3];
ll gcd(ll a, ll b) {
return b ? gcd(b, a % b) : a;
}
int main() {
scanf("%d %lld %lld", &n, &A, &B);
C = A / gcd(A, B + 1) * B;
for (int i = 1; i <= n; i++) {
scanf("%lld %lld", &l, &r);
if (r - l + 1 >= C) {
printf("%lld\n", C);
return 0;
}
l %= C, r %= C;
if (l <= r) {
sect[++tot] = make_pair(l, r);
} else {
sect[++tot] = make_pair(0, r);
sect[++tot] = make_pair(l, C - 1);
}
}
for (int i = 1; i <= tot; i++) {
temp[++m] = sect[i].first;
temp[++m] = sect[i].second + 1;
}
sort(temp + 1, temp + m + 1);
for (int i = 1; i <= tot; i++) {
int x = lower_bound(temp + 1, temp + m + 1, sect[i].first) - temp;
int y = lower_bound(temp + 1, temp + m + 1, sect[i].second + 1) - temp;
sum[x]++, sum[y]--;
}
ll ans = 0;
for (int i = 1; i <= m; i++) {
sum[i] += sum[i - 1];
if (sum[i]) {
ans += temp[i + 1] - temp[i];
}
}
printf("%lld\n", ans);
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... | ||||
