From d77d6fd3ad8fbca408ac5f15be54840fea8a4724 Mon Sep 17 00:00:00 2001 From: Kimiyuki Onaka Date: Thu, 29 Jul 2021 23:06:40 +0900 Subject: [PATCH] test: Add examples/wip/abc127_f.py --- examples/README.md | 3 +++ examples/wip/abc127_f.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 examples/wip/abc127_f.py diff --git a/examples/README.md b/examples/README.md index 2dcb1f42..f21f7021 100644 --- a/examples/README.md +++ b/examples/README.md @@ -46,6 +46,9 @@ - :warning: CE `wip/dp_w.py` - Educational DP Contest [W - Intervals](https://atcoder.jp/contests/dp/tasks/dp_w) - A lazy propagation segment tree / 遅延伝播セグメント木 +- :warning: CE `wip/abc127_f.py` + - AtCoder Beginner Contest 127 [F - Absolute Minima](https://atcoder.jp/contests/abc127/tasks/abc127_f) + - Slope trick ### Toy scripts diff --git a/examples/wip/abc127_f.py b/examples/wip/abc127_f.py new file mode 100644 index 00000000..f242c404 --- /dev/null +++ b/examples/wip/abc127_f.py @@ -0,0 +1,17 @@ +# https://atcoder.jp/contests/abc127/tasks/abc127_f +from typing import * +import jikka + +def solve(q: int, queries: List[List[int]]) -> List[Tuple[int, int]]: + f = lambda x: 0 + ans = [] + for query in queries: + if query[0] == 1: + a = query[1] + b = query[1] + f = (lambda f: lambda x: f(x) + abs(x - a) + b)(f) + else: + assert query[0] == 2 + x = epsilon x: f(x) <= f(epsilon y: y) and x <= (epsilon z: f(z) <= f(epsilon y: y)) + ans.append((x, f(x))) + return asn