# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
582928 | groshi | Strange Device (APIO19_strange_device) | C++17 | 557 ms | 77788 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<queue>
using namespace std;
#define int long long
vector<pair<int,int> > Q,pom;
int32_t main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
long long n,a,b,x,y;
cin>>n>>a>>b;
for(int i=1;i<=n;i++)
{
cin>>x>>y;
Q.push_back({x,y});
}
sort(Q.begin(),Q.end());
bool cale=0;
int cos=a*b/__gcd(a,b+1);
if(1e18/a>=b)
for(int i=0;i<Q.size();i++)
{
if(Q[i].second-Q[i].first+1>=cos)
cale=1;
}
else{
int suma=0;
for(int i=0;i<Q.size();i++)
suma+=(Q[i].second-Q[i].first+1);
cout<<suma;
return 0;
}
if(cale==1)
{
cout<<a*b;
return 0;
}
for(int i=0;i<Q.size();i++)
{
if(Q[i].second%cos>=Q[i].first%cos)
pom.push_back({Q[i].first%cos,Q[i].second%cos});
else{
pom.push_back({Q[i].first%cos,cos-1});
pom.push_back({0,Q[i].second%cos});
}
}
sort(pom.begin(),pom.end());
int wynik=0;
int maxx=-1;
maxx=pom[0].second;
int pocz=pom[0].first;
for(int i=1;i<pom.size();i++)
{
if(pom[i].first>maxx)
{
wynik+=maxx-pocz+1;
pocz=pom[i].first;
maxx=pom[i].second;
}
else maxx=max(maxx,pom[i].second);
}
wynik+=maxx-pocz+1;
cout<<wynik;
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... |