From d680398c969b95cd8cf02855a16800f4ca5732b0 Mon Sep 17 00:00:00 2001 From: nwerc-082 Date: Sun, 20 Nov 2016 10:26:26 +0000 Subject: [PATCH 1/6] ... --- C.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 C.py diff --git a/C.py b/C.py new file mode 100644 index 0000000..207bcc3 --- /dev/null +++ b/C.py @@ -0,0 +1,7 @@ +from __future__ import print_function +import sys +x, y = map(float, sys.stdin.readline().split()) +n = float(sys.stdin.readline()) +for l,u,f in ( map(float, line.split()) for line in sys.stdin ): + y -= (u-l)*(1-f) +print(x / y) From 1b9d9346a189b426088eacdfca8b23d85ad7524f Mon Sep 17 00:00:00 2001 From: nwerc-082 Date: Sun, 20 Nov 2016 10:45:39 +0000 Subject: [PATCH 2/6] ... --- E.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 E.py diff --git a/E.py b/E.py new file mode 100644 index 0000000..0577113 --- /dev/null +++ b/E.py @@ -0,0 +1,7 @@ +from __future__ import print_function +import sys +n = int(sys.stdin.readline()) +ss = map(int, sys.stdin.readline().split()) +tt = sorted(enumerate(ss), key = lambda (i,x): -x) +print(" ".join(str(x[0]+1) for x in tt) if tt[0][1] <= sum(ss)-tt[0][1] + else "impossible") From 0231d459376102f7351d25b0333ad56eced05f68 Mon Sep 17 00:00:00 2001 From: nwerc-082 Date: Sun, 20 Nov 2016 11:33:56 +0000 Subject: [PATCH 3/6] ... --- H.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 H.py diff --git a/H.py b/H.py new file mode 100644 index 0000000..ac0037f --- /dev/null +++ b/H.py @@ -0,0 +1,12 @@ +from __future__ import print_function +import sys +def to_int(x): + bs = [] + for b in x: + if bs and bs[-1]: + bs.append(0 if b == "1" else 1) + else: + bs.append(1 if b == "1" else 0) + return int("".join(map(str, bs)), 2) +n, a, b = sys.stdin.readline().split(); n = int(n) +print(to_int(b) - to_int(a) - 1) From ad2e8c1c769fb64f2a81794c26de1cd95a9fed72 Mon Sep 17 00:00:00 2001 From: nwerc-082 Date: Sun, 20 Nov 2016 13:17:04 +0000 Subject: [PATCH 4/6] ... --- F.cpp | 38 ++++++++++++++++++++++++++++++++++++++ F.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 F.cpp create mode 100644 F.py diff --git a/F.cpp b/F.cpp new file mode 100644 index 0000000..d20c308 --- /dev/null +++ b/F.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include + +using namespace std; + +long f(vector& l) +{ + long m = 0; set> s = {0}; + for(auto x : l) { + // cerr << "x = " << x << endl; + if (s.count(x) == 0) { + m = max(m, min(*s.begin(), x)); + s.insert(x); + } else { + s.erase(x); + m = max(m, min(*s.begin(), x)); + } + // cerr << "m = " << m << endl; + } + return m; +} + +int main() +{ + long n; cin >> n; vector l1(n), l2(n); + for (long i = 0; i < n; ++i) cin >> l1[i]; + for (long i = 0; i < n; ++i) cin >> l2[i]; + set s2(begin(l2), end(l2)); + set> s; vector l1_, l2_; + for (auto x : l1) if (s2.count(x) == 1) s.insert(x); + for (auto x : l1) if (s.count(x) == 0) l1_.push_back(x); + for (auto x : l2) if (s.count(x) == 0) l2_.push_back(x); + long m = *s.begin(); + cout << max(m, max(f(l1_), f(l2_))) << endl; +} diff --git a/F.py b/F.py new file mode 100644 index 0000000..e6a0b36 --- /dev/null +++ b/F.py @@ -0,0 +1,29 @@ +MOVED_TO_CPP + +from __future__ import print_function +import sys + +def f(l): + m, s, ms = 0, set(), 0 + for x in l: + if x not in s: + s.add(x) + ms = max(x, ms) + else: + s.remove(x) + ms = ... + if ms > x: + m = max(m, x) + else: + m = max(m, ms) + return m + +n = int(sys.stdin.readline()) +l1 = map(int, sys.stdin.readline().split()) +l2 = map(int, sys.stdin.readline().split()) +s2 = set(l2) +s = [ x for x in l1 if x in s2 ] +l1 = [ x for x in l1 if x not in s ] +l2 = [ x for x in l2 if x not in s ] +m = max(s) +print(max(m, max(f(l1), f(l2)))) From 3906594b73846366ea63e922caa17c4de71803d5 Mon Sep 17 00:00:00 2001 From: nwerc-082 Date: Sun, 20 Nov 2016 14:05:35 +0000 Subject: [PATCH 5/6] ... --- I.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 I.py diff --git a/I.py b/I.py new file mode 100644 index 0000000..c5f24cf --- /dev/null +++ b/I.py @@ -0,0 +1,42 @@ +from __future__ import print_function +import heapq, sys + +def dijkstra(G, s): + V, E = G; d = {}; S = set(); q = [] + for u in V: d.setdefault(u, None) + for u in s: + d[u] = 0; heapq.heappush(q, (0,u)) + while q: + n, u = heapq.heappop(q) + if u in S: continue + S.add(u) + for v in E[u]: + if d[v] is None or d[v] > d[u] + 1: + d[v] = d[u] + 1; heapq.heappush(q, (d[v],v)) + return d + +def transpose(G): + V, E = G; ET = {} + for u in V: ET[u] = [] + for u, vs in E.iteritems(): + for v in vs: ET[v].append(u) + return V, ET + +n, m, k = map(int, sys.stdin.readline().split()) +iron = [ int(x)-1 for x in sys.stdin.readline().split() ] +coal = [ int(x)-1 for x in sys.stdin.readline().split() ] +V, E = range(n), {} +for i, line in enumerate(sys.stdin): + E[i] = [ int(x)-1 for x in line.split()[1:] ] +G = V, E +GT = transpose(G) +ds = dijkstra(G, [0]) +di = dijkstra(GT, iron) +dc = dijkstra(GT, coal) +try: + m = min( ds[i]+di[i]+dc[i] for i in xrange(n) + if None not in (ds[i],di[i],dc[i]) ) + print(m) +except ValueError as e: + if "empty" not in e.args[0]: raise + print("impossible") From b97cb391e3d9904b4c3a2eb1668fe65dbc9facbb Mon Sep 17 00:00:00 2001 From: Yorick van Pelt Date: Sun, 26 Feb 2017 11:54:47 +0100 Subject: [PATCH 6/6] Add uncommitted changes --- J.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 J.py diff --git a/J.py b/J.py new file mode 100644 index 0000000..411ea1c --- /dev/null +++ b/J.py @@ -0,0 +1,7 @@ +from __future__ import print_function +import sys +n, q, s = map(int, float, sys.stdin.readline().split()) +s_to_q = map(int, float, sys.stdin.readline().split()) +q_sizes = map(int, float, sys.stdin.readline().split()) + +# alleen nog even...