Submission #1321947

#TimeUsernameProblemLanguageResultExecution timeMemory
1321947rycSnail (NOI18_snail)Pypy 3
0 / 100
1099 ms85628 KiB
import math, sys h, n = map(int,input().split()) p = list(map(int,input().split())) ans = [0, -1] def findHighestPoint(list): cpoint = 0 hpoint = 0 newlist = list.copy()*2 for i in range(len(newlist)): cpoint += newlist[i] if cpoint < 0: cpoint = 0 if cpoint > hpoint: hpoint = cpoint return hpoint SumPhases = sum(p) if SumPhases <= 0 and h - findHighestPoint(p) > 0: print('-1 -1') sys.exit() notDone = True while notDone: if h - findHighestPoint(p) <= 0: checkarr = p*2 ans[1] = -1 for i in range(len(checkarr)): h -= checkarr[i] ans[1] += 1 if h <= 0: notDone = False if i <= len(p)-1: print(ans[0], ans[1]) else : ans[0] += 1 ans[1] -= len(p) print(ans[0], ans[1]) break else: h -= SumPhases ans[0] += 1

Compilation message (stdout)

Compiling 'snail.py'...

=======
  adding: __main__.pyc (deflated 35%)

=======
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...