Submission #9772299
Source Code Expand
from collections import namedtuple
Robot = namedtuple('Robot', ['end_pos', 'start_pos'])
class Solver:
def __init__(self, n, robots):
self.n = n
self.robots = robots
def order_by_endpos(self, robots):
return map(lambda x:Robot(x[0], x[1]), sorted(map(lambda x:(x[0]+x[1], max(x[0]-x[1], 1)), robots)))
def solve(self):
current_pos = 0
keep = 0
for r in self.order_by_endpos(self.robots):
if current_pos <= r.start_pos:
keep += 1
current_pos = r.end_pos
return keep
if __name__ == "__main__":
n = int(input())
robots = []
for _ in range(n):
robots.append(tuple(map(int, input().split())))
s = Solver(n, robots)
print(s.solve())
Submission Info
| Submission Time | |
|---|---|
| Task | B - Robot Arms |
| User | hagino3000 |
| Language | Python (3.4.3) |
| Score | 200 |
| Code Size | 804 Byte |
| Status | AC |
| Exec Time | 557 ms |
| Memory | 30808 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample-01.txt, sample-02.txt, sample-03.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, sample-01.txt, sample-02.txt, sample-03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 532 ms | 29216 KiB |
| 02.txt | AC | 544 ms | 29828 KiB |
| 03.txt | AC | 547 ms | 30028 KiB |
| 04.txt | AC | 557 ms | 29968 KiB |
| 05.txt | AC | 522 ms | 27612 KiB |
| 06.txt | AC | 529 ms | 27608 KiB |
| 07.txt | AC | 533 ms | 30792 KiB |
| 08.txt | AC | 268 ms | 16320 KiB |
| 09.txt | AC | 260 ms | 17096 KiB |
| 10.txt | AC | 266 ms | 17100 KiB |
| 11.txt | AC | 527 ms | 29188 KiB |
| 12.txt | AC | 538 ms | 30808 KiB |
| 13.txt | AC | 21 ms | 3444 KiB |
| sample-01.txt | AC | 21 ms | 3444 KiB |
| sample-02.txt | AC | 21 ms | 3444 KiB |
| sample-03.txt | AC | 21 ms | 3444 KiB |