Submission #551424

# Submission time Handle Problem Language Result Execution time Memory
551424 2022-04-20T15:47:34 Z jh05013 None (KRIII5P_3) Python 3
0 / 7
730 ms 42788 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(100000): pow2.append(pow2[-1]*2 % MOD)

n = int(input())
ev_l = {}
ev_r = {}
for i in range(n):
    l, r = MIS()
    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 54 ms 6936 KB Output is correct
2 Correct 54 ms 6924 KB Output is correct
3 Correct 57 ms 6952 KB Output is correct
4 Correct 50 ms 6880 KB Output is correct
5 Correct 48 ms 6864 KB Output is correct
6 Correct 71 ms 7064 KB Output is correct
7 Correct 72 ms 7060 KB Output is correct
8 Correct 68 ms 7076 KB Output is correct
9 Correct 66 ms 7096 KB Output is correct
10 Correct 80 ms 7184 KB Output is correct
11 Correct 270 ms 8876 KB Output is correct
12 Correct 265 ms 8852 KB Output is correct
13 Correct 254 ms 8784 KB Output is correct
14 Correct 276 ms 8868 KB Output is correct
15 Correct 269 ms 8784 KB Output is correct
16 Incorrect 730 ms 42788 KB Output isn't correct
17 Halted 0 ms 0 KB -