| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 363856 | Mahdi_Shokoufi | 이상한 기계 (APIO19_strange_device) | C++17 | 732 ms | 81004 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long ll;
const ll inf = 1e18 + 10;
int main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll n, a, b;
cin >> n >> a >> b;
ll p = (inf / b < a / __gcd(a, b + 1) ? inf : a / __gcd(a, b + 1) * b);
set < pair < ll , ll > > st;
for (int i = 0; i < n; i ++){
ll l, r;
cin >> l >> r;
if (p <= r - l + 1)
return cout << p, 0;
l %= p; r %= p;
if (l <= r)
st.insert(mp(l, -r));
else
st.insert(mp(l, -p + 1)), st.insert(mp(0, -r));
}
ll ans = 0, mx = -1;
for (auto itr = st.begin(); itr != st.end(); itr ++){
ll x = itr -> first, y = -(itr -> second);
ans += max(0LL, y - max(mx + 1, x) + 1);
mx = max(mx, y);
}
cout << ans;
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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
