| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 206167 | AlexLuchianov | 이상한 기계 (APIO19_strange_device) | C++14 | 829 ms | 47292 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
using ll = long long;
using ld = long double;
ll const inf = 1000000000000000000;
ll period(ll a, ll b){
ll p = __gcd(a, b + 1);
if(a / p <= inf / b)
return a / p * b;
return inf + 1;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
ll a, b;
cin >> n >> a >> b;
ll pi = period(a, b);
if(inf < pi){
ll result = 0;
for(int i = 1;i <= n; i++){
ll x, y;
cin >> x >> y;
result += y - x + 1;
}
cout << result;
} else {
vector<pair<ll,int>> event;
for(int i = 1;i <= n; i++){
ll x, y;
cin >> x >> y;
if(y - x < pi){
if(x % pi <= y % pi){
event.push_back({x % pi, 1});
event.push_back({y % pi + 1, -1});
} else {
event.push_back({x % pi, 1});
event.push_back({pi, -1});
event.push_back({0, 1});
event.push_back({y % pi + 1, -1});
}
} else {
cout << pi;
return 0;
}
}
sort(event.begin(), event.end());
ll result = 0, last = 0, sum = 0;
for(int i = 0; i < event.size(); i++){
if(0 < sum)
result += event[i].first - last;
last = event[i].first;
sum += event[i].second;
}
cout << result;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
