# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
551426 |
2022-04-20T15:49:08 Z |
jh05013 |
None (KRIII5P_3) |
Python 3 |
|
704 ms |
42868 KB |
import sys;input=lambda:sys.stdin.readline().strip('\n')
MIS = lambda: map(int,input().split())
MOD = 10**9+7
pow2 = [1]
for i in range(100003): pow2.append(pow2[-1]*2 % MOD)
n = int(input())
ev_l = {}
ev_r = {}
for i in range(n):
l, r = MIS()
if l >= r: continue
ev_l[l] = ev_l.get(l, 0) + 1
ev_r[r] = ev_r.get(r, 0) + 1
pnts = sorted(set(list(ev_l.keys()) + list(ev_r.keys())))
ans0 = ans1 = 0
lay = 0
for i in range(len(pnts)-1):
l, r = pnts[i], pnts[i+1]
lay-= ev_r.get(l, 0)
lay_old = lay
lay+= ev_l.get(l, 0)
ans0+= (pow2[lay]-1) * (r-l)
ans1+= pow2[lay] - pow2[lay_old]
print(ans0%MOD, ans1%MOD)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
6884 KB |
Output is correct |
2 |
Correct |
48 ms |
6888 KB |
Output is correct |
3 |
Correct |
44 ms |
6940 KB |
Output is correct |
4 |
Correct |
42 ms |
6836 KB |
Output is correct |
5 |
Correct |
46 ms |
6872 KB |
Output is correct |
6 |
Correct |
62 ms |
6856 KB |
Output is correct |
7 |
Correct |
65 ms |
6848 KB |
Output is correct |
8 |
Correct |
64 ms |
6872 KB |
Output is correct |
9 |
Correct |
66 ms |
6840 KB |
Output is correct |
10 |
Correct |
61 ms |
6952 KB |
Output is correct |
11 |
Correct |
240 ms |
6956 KB |
Output is correct |
12 |
Correct |
251 ms |
6884 KB |
Output is correct |
13 |
Correct |
262 ms |
6960 KB |
Output is correct |
14 |
Correct |
266 ms |
6956 KB |
Output is correct |
15 |
Correct |
256 ms |
6956 KB |
Output is correct |
16 |
Correct |
428 ms |
22812 KB |
Output is correct |
17 |
Correct |
423 ms |
24744 KB |
Output is correct |
18 |
Correct |
416 ms |
24884 KB |
Output is correct |
19 |
Correct |
415 ms |
24836 KB |
Output is correct |
20 |
Correct |
236 ms |
9868 KB |
Output is correct |
21 |
Correct |
673 ms |
42836 KB |
Output is correct |
22 |
Correct |
678 ms |
42860 KB |
Output is correct |
23 |
Correct |
696 ms |
42824 KB |
Output is correct |
24 |
Correct |
663 ms |
42852 KB |
Output is correct |
25 |
Correct |
242 ms |
7640 KB |
Output is correct |
26 |
Correct |
519 ms |
27016 KB |
Output is correct |
27 |
Correct |
444 ms |
25424 KB |
Output is correct |
28 |
Correct |
377 ms |
17092 KB |
Output is correct |
29 |
Correct |
347 ms |
16876 KB |
Output is correct |
30 |
Correct |
324 ms |
16276 KB |
Output is correct |
31 |
Correct |
311 ms |
14188 KB |
Output is correct |
32 |
Correct |
287 ms |
10788 KB |
Output is correct |
33 |
Correct |
275 ms |
10116 KB |
Output is correct |
34 |
Correct |
245 ms |
9296 KB |
Output is correct |
35 |
Correct |
243 ms |
8920 KB |
Output is correct |
36 |
Correct |
671 ms |
42808 KB |
Output is correct |
37 |
Correct |
672 ms |
42860 KB |
Output is correct |
38 |
Correct |
691 ms |
42868 KB |
Output is correct |
39 |
Correct |
682 ms |
42792 KB |
Output is correct |
40 |
Correct |
704 ms |
42816 KB |
Output is correct |
41 |
Correct |
50 ms |
6992 KB |
Output is correct |
42 |
Correct |
49 ms |
6896 KB |
Output is correct |
43 |
Correct |
58 ms |
7456 KB |
Output is correct |
44 |
Correct |
57 ms |
7400 KB |
Output is correct |
45 |
Correct |
240 ms |
15404 KB |
Output is correct |
46 |
Correct |
232 ms |
15268 KB |
Output is correct |
47 |
Correct |
255 ms |
15416 KB |
Output is correct |
48 |
Correct |
445 ms |
23440 KB |
Output is correct |
49 |
Correct |
436 ms |
24840 KB |
Output is correct |
50 |
Correct |
450 ms |
24932 KB |
Output is correct |