# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
122791 | abacaba | 이상한 기계 (APIO19_strange_device) | C++14 | 892 ms | 39916 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 15;
int n;
long long t, a, b, l, r, ans;
vector <pair <long long, int> > temp;
stack <long long> st;
int main() {
scanf("%d%lld%lld", &n, &a, &b);
if((b + 1) % a == 0)
t = b;
else {
t = a / __gcd(a, b + 1);
t *= b;
}
while(n--) {
scanf("%lld%lld", &l, &r);
if(r - l + 1 >= t)
return cout << t, 0;
l %= t, r %= t;
if(l > r) {
temp.push_back({l, -1});
temp.push_back({t, 1});
temp.push_back({0, -1});
temp.push_back({r + 1, 1});
}
else {
temp.push_back({l, -1});
temp.push_back({r + 1, 1});
}
}
sort(temp.begin(), temp.end());
for(auto i : temp) {
if(i.second == 1) {
if(st.size() == 1)
ans += i.first - st.top();
st.pop();
}
else
st.push(i.first);
}
printf("%lld", ans);
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... |