File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import sys
2+
3+ def main ():
4+ input = sys .stdin .readline
5+ N = int (input ())
6+ pair = []
7+ totalA = 0
8+
9+ for _ in range (N ):
10+ X , A = map (int , input ().split ())
11+ pair .append ((X , A ))
12+ totalA += A
13+
14+ pair .sort (key = lambda x :x [0 ])
15+
16+ medium = (totalA + 1 ) // 2
17+
18+ sumA = 0
19+
20+ for x , a in pair :
21+ sumA += a
22+
23+ if sumA >= medium :
24+ print (x )
25+ break
26+
27+
28+ if __name__ == '__main__' :
29+ main ()
Original file line number Diff line number Diff line change 1+ import sys
2+
3+ def main ():
4+ input = sys .stdin .readline
5+ N = int (input ())
6+
7+ calendar = [0 for _ in range (366 )]
8+
9+ for _ in range (N ):
10+ S , E = map (int , input ().split ())
11+ for date in range (S , E + 1 ):
12+ calendar [date ] += 1
13+
14+ total = 0
15+ maxHeight = 0
16+ count = 0
17+
18+ for date in range (len (calendar )):
19+ if calendar [date ] != 0 :
20+ maxHeight = max (calendar [date ], maxHeight )
21+ count += 1
22+ else :
23+ total += count * maxHeight
24+ count = 0
25+ maxHeight = 0
26+
27+ if count > 0 :
28+ total += count * maxHeight
29+
30+ print (total )
31+
32+ if __name__ == '__main__' :
33+ main ()
You can’t perform that action at this time.
0 commit comments