Skip to content

Instantly share code, notes, and snippets.

@op01
Created May 13, 2014 16:10
Show Gist options
  • Save op01/4d1bbc2af0fb0293048f to your computer and use it in GitHub Desktop.
Save op01/4d1bbc2af0fb0293048f to your computer and use it in GitHub Desktop.
TOI10th day1 monkey
class Bar:
def __init__(self,s):
p,h = s.split(' ')
self.p = int(p)
self.h = int(h)
n,m,k = (int(i) for i in input().split(' '))
b = [int(i) for i in input().split(' ')[0:m]]
bars = [Bar(input()) for i in range(k)]
st = int(input())
st-=1
bars.sort(key=lambda x:-x.h)
for i in bars:
b[i.p],b[i.p-1]=b[i.p-1],b[i.p]
earth = b[st]
best = earth
best = max(b[max(st-1,0):min(st+2,m)])
bars.reverse()
for i in bars:
b[i.p],b[i.p-1]=b[i.p-1],b[i.p]
if st==i.p:st-=1
elif st==i.p-1:st+=1
best = max(max(b[max(st-1,0):min(st+2,m)]),best)
print(best)
print(["USE","NO"][best==earth])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment