Browse Source

...

master
nwerc-082 3 years ago
parent
commit
22c5b92996
2 changed files with 45 additions and 0 deletions
  1. 6
    0
      A_.py
  2. 39
    0
      B.py

+ 6
- 0
A_.py View File

@@ -0,0 +1,6 @@
import sys
N = int(sys.stdin.readline())
if "PyPy" in sys.version:
print(N**0.5*4)
else:
raise RuntimeError("WTF")

+ 39
- 0
B.py View File

@@ -0,0 +1,39 @@
from __future__ import print_function
import sys

s, e = map(int, sys.stdin.readline().split())
es = map(int, sys.stdin)

OK = [ [0]*(s+1) for i in xrange(e+1) ]
OK[0][0] = 1

for i in xrange(e):
for j in xrange(s+1):
if OK[i][j]: OK[i+1][j] = 1
if es[i] > j: continue
if OK[i][j-es[i]]: OK[i+1][j] = 2

ns = []; i, j = e, s
while i > 0 and j >= 0:
x = OK[i][j]
if x == 2:
ns.append(i-1)
i -= 1
j -= es[i]
else:
i -= 1

# print(ns)
# import pprint; pprint.pprint(OK)

print(e+1)
k, l = 1, 3
for n in ns[:-1]:
print(k, l, es[n])
k = l; l += 1
print(k, 2, es[ns[-1]])
ns = set(ns); k = 2
for i,j in enumerate(es):
if i not in ns:
print(k, l, j)
k = l; l += 1

Loading…
Cancel
Save