# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
979299 | nnin | Strange Device (APIO19_strange_device) | C++17 | 386 ms | 54476 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define pii pair<ll,ll>
#define f first
#define s second
#define ll long long
int n;
ll A, B;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>A>>B;
ll g = __gcd(A, B+1);
A /= g;
vector<pii> v;
bool all = 0;
for(int i=0;i<n;i++) {
ll l, r;
cin>>l>>r;
if(all) continue;
ll x = l/A;
x /= B;
ll y = r/A;
y /= B;
if(x==0 && y==0) {
v.push_back({l, r});
} else if(x==y) {
v.push_back({l%(A*B), r%(A*B)});
} else if(x+1==y) {
v.push_back({l%(A*B), (A*B)-1});
v.push_back({0, r%(A*B)});
} else {
all = 1;
}
}
if(all) {
cout<<A*B;
return 0;
}
sort(v.begin(), v.end());
ll ct = 0, last = -1;
for(int i=0;i<v.size();i++) {
if(last>=v[i].s) continue;
if(last<v[i].f) last = v[i].f-1;
ct += v[i].s-last;
last = v[i].s;
}
cout<<ct;
}
컴파일 시 표준 에러 (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... |