이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > vec;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, a, b, num, curl, curr, ans=0;
cin >> n >> a >> b;
num=a*b/gcd(a*b, b+1);
for (long long i=1; i<=n; i++)
{
long long l, r;
cin >> l >> r;
if (l+num<=r)
vec.push_back({0, num-1});
else if (l%num<=r%num)
vec.push_back({l%num, r%num});
else
{
vec.push_back({l%num, num-1});
vec.push_back({0, r%num});
}
}
sort(vec.begin(), vec.end());
curl=vec[0].first;
curr=vec[0].second;
for (long long i=1; i<vec.size(); i++)
{
if (curr<vec[i].first)
{
ans+=curr-curl+1;
curl=vec[i].first;
}
curr=max(curr, vec[i].second);
}
cout << ans+curr-curl+1;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
strange_device.cpp: In function 'int main()':
strange_device.cpp:29:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for (long long i=1; i<vec.size(); i++)
| ~^~~~~~~~~~~
# | 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... |