답안 #636869

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
636869 2022-08-30T10:35:49 Z beaconmc 이상한 기계 (APIO19_strange_device) PyPy 3
100 / 100
1619 ms 353536 KB
import sys
input = lambda: sys.stdin.readline().strip()
from math import *
n,a,b = map(int, input().split())

def lcm(a,b):
  return a*b//gcd(a,b)

ranges = []
for i in range(n):
    ranges.append(list(map(int, input().split())))

k = (lcm(a,b+1)//(b+1)) * b

new = []
ans = 0
flag = False
for i in ranges:
    if i[1]-i[0]+1 >= k:
        flag = True
    if i[0]%k > i[1]%k:
        new.append([i[0]%k,k-1])
        new.append([0,i[1]%k])
    else:
        new.append([i[0]%k, i[1]%k])
new.sort()

realnew = []
if flag:
    print(k)
else:
    cur = k
    for i in range(len(new)):
        if not realnew:
            realnew.append(new[i])
            continue
        if realnew[-1][1] >= new[i][0]:
            realnew[-1][1] = max(realnew[-1][1],new[i][1])
        else:
            realnew.append(new[i])
    for i in realnew:
        ans += i[1]-i[0]+1
    print(ans)
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 18268 KB Output is correct
2 Correct 75 ms 23088 KB Output is correct
3 Correct 66 ms 23084 KB Output is correct
4 Correct 34 ms 18180 KB Output is correct
5 Correct 33 ms 18204 KB Output is correct
6 Correct 33 ms 18220 KB Output is correct
7 Correct 37 ms 18264 KB Output is correct
8 Correct 47 ms 18132 KB Output is correct
9 Correct 41 ms 18224 KB Output is correct
10 Correct 34 ms 18188 KB Output is correct
11 Correct 33 ms 18220 KB Output is correct
12 Correct 32 ms 18264 KB Output is correct
13 Correct 33 ms 18244 KB Output is correct
14 Correct 35 ms 18228 KB Output is correct
15 Correct 37 ms 18264 KB Output is correct
16 Correct 91 ms 23452 KB Output is correct
17 Correct 200 ms 50964 KB Output is correct
18 Correct 34 ms 18244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 18212 KB Output is correct
2 Correct 34 ms 18220 KB Output is correct
3 Correct 41 ms 18176 KB Output is correct
4 Correct 34 ms 18168 KB Output is correct
5 Correct 36 ms 18244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 18272 KB Output is correct
2 Correct 48 ms 19276 KB Output is correct
3 Correct 46 ms 19284 KB Output is correct
4 Correct 45 ms 19224 KB Output is correct
5 Correct 1323 ms 268040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 18152 KB Output is correct
2 Correct 1570 ms 316256 KB Output is correct
3 Correct 1546 ms 312088 KB Output is correct
4 Correct 1590 ms 349296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 18152 KB Output is correct
2 Correct 1570 ms 316256 KB Output is correct
3 Correct 1546 ms 312088 KB Output is correct
4 Correct 1590 ms 349296 KB Output is correct
5 Correct 32 ms 18256 KB Output is correct
6 Correct 1583 ms 349144 KB Output is correct
7 Correct 1529 ms 349204 KB Output is correct
8 Correct 1543 ms 349204 KB Output is correct
9 Correct 1576 ms 349260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 18152 KB Output is correct
2 Correct 1570 ms 316256 KB Output is correct
3 Correct 1546 ms 312088 KB Output is correct
4 Correct 1590 ms 349296 KB Output is correct
5 Correct 33 ms 18220 KB Output is correct
6 Correct 224 ms 50300 KB Output is correct
7 Correct 199 ms 49824 KB Output is correct
8 Correct 198 ms 50500 KB Output is correct
9 Correct 208 ms 50924 KB Output is correct
10 Correct 229 ms 50632 KB Output is correct
11 Correct 202 ms 49808 KB Output is correct
12 Correct 199 ms 50000 KB Output is correct
13 Correct 214 ms 50824 KB Output is correct
14 Correct 199 ms 50400 KB Output is correct
15 Correct 199 ms 50944 KB Output is correct
16 Correct 218 ms 50956 KB Output is correct
17 Correct 201 ms 50880 KB Output is correct
18 Correct 1595 ms 322500 KB Output is correct
19 Correct 1559 ms 317984 KB Output is correct
20 Correct 1572 ms 318068 KB Output is correct
21 Correct 209 ms 50640 KB Output is correct
22 Correct 213 ms 50932 KB Output is correct
23 Correct 541 ms 118868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 18228 KB Output is correct
2 Correct 194 ms 46144 KB Output is correct
3 Correct 202 ms 47156 KB Output is correct
4 Correct 1535 ms 312132 KB Output is correct
5 Correct 228 ms 47152 KB Output is correct
6 Correct 194 ms 47236 KB Output is correct
7 Correct 200 ms 47248 KB Output is correct
8 Correct 189 ms 47176 KB Output is correct
9 Correct 189 ms 47124 KB Output is correct
10 Correct 217 ms 47140 KB Output is correct
11 Correct 201 ms 47156 KB Output is correct
12 Correct 190 ms 47240 KB Output is correct
13 Correct 190 ms 47236 KB Output is correct
14 Correct 1527 ms 312048 KB Output is correct
15 Correct 201 ms 50180 KB Output is correct
16 Correct 1619 ms 353536 KB Output is correct
17 Correct 1565 ms 353448 KB Output is correct
18 Correct 33 ms 18208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 18268 KB Output is correct
2 Correct 75 ms 23088 KB Output is correct
3 Correct 66 ms 23084 KB Output is correct
4 Correct 34 ms 18180 KB Output is correct
5 Correct 33 ms 18204 KB Output is correct
6 Correct 33 ms 18220 KB Output is correct
7 Correct 37 ms 18264 KB Output is correct
8 Correct 47 ms 18132 KB Output is correct
9 Correct 41 ms 18224 KB Output is correct
10 Correct 34 ms 18188 KB Output is correct
11 Correct 33 ms 18220 KB Output is correct
12 Correct 32 ms 18264 KB Output is correct
13 Correct 33 ms 18244 KB Output is correct
14 Correct 35 ms 18228 KB Output is correct
15 Correct 37 ms 18264 KB Output is correct
16 Correct 91 ms 23452 KB Output is correct
17 Correct 200 ms 50964 KB Output is correct
18 Correct 34 ms 18244 KB Output is correct
19 Correct 34 ms 18212 KB Output is correct
20 Correct 34 ms 18220 KB Output is correct
21 Correct 41 ms 18176 KB Output is correct
22 Correct 34 ms 18168 KB Output is correct
23 Correct 36 ms 18244 KB Output is correct
24 Correct 32 ms 18272 KB Output is correct
25 Correct 48 ms 19276 KB Output is correct
26 Correct 46 ms 19284 KB Output is correct
27 Correct 45 ms 19224 KB Output is correct
28 Correct 1323 ms 268040 KB Output is correct
29 Correct 33 ms 18152 KB Output is correct
30 Correct 1570 ms 316256 KB Output is correct
31 Correct 1546 ms 312088 KB Output is correct
32 Correct 1590 ms 349296 KB Output is correct
33 Correct 32 ms 18256 KB Output is correct
34 Correct 1583 ms 349144 KB Output is correct
35 Correct 1529 ms 349204 KB Output is correct
36 Correct 1543 ms 349204 KB Output is correct
37 Correct 1576 ms 349260 KB Output is correct
38 Correct 33 ms 18220 KB Output is correct
39 Correct 224 ms 50300 KB Output is correct
40 Correct 199 ms 49824 KB Output is correct
41 Correct 198 ms 50500 KB Output is correct
42 Correct 208 ms 50924 KB Output is correct
43 Correct 229 ms 50632 KB Output is correct
44 Correct 202 ms 49808 KB Output is correct
45 Correct 199 ms 50000 KB Output is correct
46 Correct 214 ms 50824 KB Output is correct
47 Correct 199 ms 50400 KB Output is correct
48 Correct 199 ms 50944 KB Output is correct
49 Correct 218 ms 50956 KB Output is correct
50 Correct 201 ms 50880 KB Output is correct
51 Correct 1595 ms 322500 KB Output is correct
52 Correct 1559 ms 317984 KB Output is correct
53 Correct 1572 ms 318068 KB Output is correct
54 Correct 209 ms 50640 KB Output is correct
55 Correct 213 ms 50932 KB Output is correct
56 Correct 541 ms 118868 KB Output is correct
57 Correct 34 ms 18228 KB Output is correct
58 Correct 194 ms 46144 KB Output is correct
59 Correct 202 ms 47156 KB Output is correct
60 Correct 1535 ms 312132 KB Output is correct
61 Correct 228 ms 47152 KB Output is correct
62 Correct 194 ms 47236 KB Output is correct
63 Correct 200 ms 47248 KB Output is correct
64 Correct 189 ms 47176 KB Output is correct
65 Correct 189 ms 47124 KB Output is correct
66 Correct 217 ms 47140 KB Output is correct
67 Correct 201 ms 47156 KB Output is correct
68 Correct 190 ms 47240 KB Output is correct
69 Correct 190 ms 47236 KB Output is correct
70 Correct 1527 ms 312048 KB Output is correct
71 Correct 201 ms 50180 KB Output is correct
72 Correct 1619 ms 353536 KB Output is correct
73 Correct 1565 ms 353448 KB Output is correct
74 Correct 33 ms 18208 KB Output is correct
75 Correct 35 ms 18248 KB Output is correct
76 Correct 43 ms 18188 KB Output is correct
77 Correct 35 ms 18216 KB Output is correct
78 Correct 33 ms 18220 KB Output is correct
79 Correct 79 ms 23324 KB Output is correct
80 Correct 1518 ms 318852 KB Output is correct
81 Correct 1506 ms 318300 KB Output is correct
82 Correct 1578 ms 318304 KB Output is correct
83 Correct 1570 ms 318448 KB Output is correct
84 Correct 1556 ms 318236 KB Output is correct
85 Correct 1550 ms 318332 KB Output is correct
86 Correct 559 ms 118624 KB Output is correct
87 Correct 40 ms 18220 KB Output is correct