제출 #401380

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
4013802021-05-10 05:07:39ZikXewen이상한 기계 (APIO19_strange_device)C++17
35 / 100
526 ms41444 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair<int64, int64> ii;
int N;
int64 A, B, per, ans;
vector<ii> ar;
int main(){
ios::sync_with_stdio(0), cin.tie(0);
cin >> N >> A >> B;
if(A / __gcd(A, B + 1) >= LLONG_MAX / B) per = LLONG_MAX;
per = A / __gcd(A, B + 1) * B;
for(int64 i = 0, u, v; i < N; ++i){
cin >> u >> v;
if(v - u + 1 >= per) {cout << per; return 0;}
u %= per, v %= per;
if(u <= v) ar.emplace_back(u, v);
else ar.emplace_back(u, per - 1), ar.emplace_back(0, v);
}
sort(ar.begin(), ar.end());
for(int64 i = 0, l = 0, r = -1;; ++i){
if(i == ar.size()) {ans += r - l + 1; break;}
if(ar[i].first <= r) r = max(r, ar[i].second);
else ans += r - l + 1, l = ar[i].first, r = ar[i].second;
}
cout << ans;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

컴파일 시 표준 에러 (stderr) 메시지

strange_device.cpp: In function 'int main()':
strange_device.cpp:22:14: warning: comparison of integer expressions of different signedness: 'int64' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         if(i == ar.size()) {ans += r - l + 1; break;}
      |            ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...