# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
781905 | makanhulia | Strange Device (APIO19_strange_device) | C++17 | 376 ms | 18580 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
int c = a / gcd(a, b + 1);
if(c > 1e18 / b) c = 1e18;
else c *= b;
vector<pair<int, int>> v;
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';
}
컴파일 시 표준 에러 (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... |