# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
255059 | BamiTorabi | 이상한 기계 (APIO19_strange_device) | C++14 | 610 ms | 37496 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Sasayego! Sasayego! Shinzou wo Sasageyo!
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bitset>
#include <ctime>
#define debug(x) cerr << #x << " = " << x << endl
#define lid (id << 1)
#define rid (lid ^ 1)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
const int maxN = 2e6 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
int cnt = 0, len = 0;
pll P[maxN], Q[maxN];
pll I(pll X, pll Y){
if (X > Y)
swap(X, Y);
pll Z;
Z.first = Y.first;
Z.second = X.second;
if (Z.first > Z.second)
Z = {-1, -1};
return Z;
}
pll U(pll X, pll Y){
if (X > Y)
swap(X, Y);
pll Z;
Z.first = X.first;
Z.second = Y.second;
return Z;
}
int main(){
time_t START = clock();
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n; ll A, B; scanf("%d%lld%lld", &n, &A, &B);
while (n--){
ll l, r; scanf("%lld%lld", &l, &r);
if (A <= (r - l + 1) / B)
return printf("%lld\n", A * B), 0;
if (A <= l / B)
l %= A * B;
if (A <= r / B)
r %= A * B;
if (r >= l)
P[cnt++] = {l, r};
else{
P[cnt++] = {l, A * B - 1};
P[cnt++] = {0, r};
}
}
sort(P, P + cnt);
Q[0] = P[0];
for (int i = 1; i < cnt; i++){
if (I(Q[len], P[i]).first == -1)
Q[++len] = P[i];
else
Q[len] = U(Q[len], P[i]);
}
ll ans = len + 1;
for (int i = 0; i <= len; i++)
ans += Q[i].second - Q[i].first;
printf("%lld\n", ans);
time_t FINISH = clock();
cerr << "Execution time: " << (ld)(FINISH - START) / CLOCKS_PER_SEC * 1000.0 << " milliseconds.\n";
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... |