diff options
author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-02-15 21:05:21 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-02-16 14:57:43 +0700 |
commit | 2b91f9554b326aea138bd8a0acbfaa10d9ad59aa (patch) | |
tree | 10053cf99e42711999d33b422a8735c5367d339f /codechef/frogs.py | |
parent | 0cf49da1527983b9d165cd394b82c6bcbcafca60 (diff) | |
download | cp-2b91f9554b326aea138bd8a0acbfaa10d9ad59aa.tar.gz |
[codechef] Try CP again after almost a year
Diffstat (limited to 'codechef/frogs.py')
-rwxr-xr-x | codechef/frogs.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/codechef/frogs.py b/codechef/frogs.py new file mode 100755 index 0000000..23f51e5 --- /dev/null +++ b/codechef/frogs.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +for t in range(int(input())): + n = int(input()) + w, l = list(map(int, input().split())), list(map(int, input().split())) + last, result, frogs = -1, 0, sorted(zip(w, range(n), l)) + for weight, position, length in frogs: + hits = 0 if position > last else (last-position)//length + 1 + last = position + hits*length + result += hits + print(result) |