| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 975052 | hirayuu_oj | 이상한 기계 (APIO19_strange_device) | C++17 | 378 ms | 54036 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) x.begin(),x.end()
using ll=long long;
const ll INF=1LL<<61;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n,A,B;
cin>>n>>A>>B;
ll g=__gcd(A,B+1);
A/=g;
ll rp=A*B;
if((INF/A)/B==0LL){
rp=INF;
}
vector<pair<ll,ll>> segs;
rep(i,n){
ll l,r;
cin>>l>>r;
r++;
if(r-l>=rp){
cout<<rp<<"\n";
return 0;
}
l%=rp;
r%=rp;
if(l<r){
segs.emplace_back(pair<ll,ll>(l,r));
}
if(l>r){
segs.emplace_back(pair<ll,ll>(l,rp));
segs.emplace_back(pair<ll,ll>(0,r));
}
}
sort(all(segs));
ll lf=0,ri=0;
ll ans=0;
for(auto &[nl,nr]:segs){
if(nl<ri){
ri=max(ri,nr);
}
else{
ans+=ri-lf;
lf=nl;
ri=nr;
}
}
ans+=ri-lf;
cout<<ans<<"\n";
}| # | 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... | ||||
