| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 781888 | kebine | 이상한 기계 (APIO19_strange_device) | C++17 | 347 ms | 19576 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define keish ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
int n, a, b, l, r;
signed main(){
keish;
cin >> n >> a >> b;
vector<pair<int, int>> v;
int c = a / gcd(a, b + 1) * b;
bool ok = 0;
for(int i = 0; i < n; i++){
cin >> l >> r;
if(r - l + 1 >= c){
ok = 1;
}
l %= c, r %= c;
if(l <= r){
v.push_back({l, r});
}else{
v.push_back({l, c - 1});
v.push_back({0, r});
}
}
if(ok){
cout << c << '\n';
return 0;
}
sort(v.begin(), v.end());
int lf = v[0].fi, rg = v[0].se;
int ans = 0;
for(int i = 1; i < v.size(); i++){
if(v[i].fi > rg){
ans += rg - lf + 1;
lf = v[i].fi, rg = v[i].se;
}
rg = max(rg, v[i].se);
}
ans += rg - lf + 1;
cout << ans << '\n';
} Compilation message (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... | ||||
