Problem:


Score : 700 points

Problem Statement

N people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i.

Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below.

At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins.

Mr. Takahashi can set the value of positive integer P independently at each step.

He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash.

Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.

Constraints

1 ≦ | N | ≦ 100000

1 ≦ A_i ≦ 10^9(1 ≦ i ≦ N)

All inputs are integers.

Input

Inputs are provided from Standard Inputs in the following form.

N
A_1
:
A_N

Output

Output an integer representing the maximum number of products Mr. Takahashi can sell.

Sample Input 1

3
3
2
5

Sample Output 1

3

As values of P, select in order 1, 4, 1.

Sample Input 2

15
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9

Sample Output 2

18



Sample input:
3
3
2
5


Sample output:
3

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[0]*N
for i in range(N):
    a[i]=int(input())

minimum=1
count=0
for i in  a:
   if(minimum<i):
       if i%minimum:
           count+= i//minimum
           print("a:",i,"minimum:",minimum,"count:",count)
           minimum=max(2,minimum)
       else :
           count+= (i//minimum-1)
           print("a:",i,"minimum:",minimum,"count:",count)
           minimum=max(2,minimum)
   else:
       minimum=max(minimum,i+1)
       print("a:",i,"minimum:",minimum,"count:",count)
print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created:  2016-10-10
#

# Usage
#
"""

def read_value():
    num_customer = int(input())

    return [int(input()) for _ in range(num_customer)]


def greed_canceler(customers):
    """

    >>> greed_canceler([3,2,5])
    3
    >>> greed_canceler([3,1,4,1,5,9,2,6,5,3,5,8,9,7,9])
    18
    """
    selled = 0
    must_above = 1
    for i, n in enumerate(customers):
        flag = False
        while must_above < customers[i]:
            flag = True
            selled += 1
            #print("Processing col: {0} of {1}".format(i, customers[i]))
            customers[i] = customers[i] - must_above
            #print("must_above: {0}".format(must_above))
            #print(customers[i])
        if not must_above < customers[i]:
            must_above = customers[i] + 1


    return selled

if __name__ == "__main__":
    import doctest
    doctest.testmod()

    greed_canceler(read_value())

Submission status: Wrong Answer

Solution code:
N = int(raw_input().strip())
A = [int(raw_input().strip()) for i in xrange(N)]

minP = 1
count = 0
tar = 0
minC = minP

while True:
  if A[tar] > minC:
    count += 1
    A[tar] -= minC
  else:
    tar += 1
    if tar == N:
      break
    if A[tar] == minC:
      minC += 1
    else:
      minC += 0
  if tar == N:
    break

print count

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
A = []

for i in range(0, N):
    A.append(int(raw_input()))

count = 0

while True:
    prev_A = A[:]
    current_position = N-1
    tmp_P = 0
    while True:
        if current_position < 0:
            break
        if current_position > 0:
            ended_A = A[:current_position+1] 
        if A[current_position] > 1:
            tmp_P += 1
        else:
            current_position -= 1
            tmp_P = 0
            continue
        if tmp_P > A[current_position]:
            current_position -= 1
            tmp_P = 0
            continue
        if current_position > 0:
            if any(x == tmp_P for x in ended_A):
                continue
            if any(x > tmp_P for x in ended_A[:-1]):
                continue
        A[current_position] -= tmp_P
        print A
        tmp_P = 0
        count += 1
    if all(x == y for x, y in zip(prev_A, A)):
        break
print count

Submission status: Wrong Answer

Solution code:
N = int(raw_input().strip())
A = [int(raw_input().strip()) for i in xrange(N)]

minP = 1
count = 0
tar = 0
minC = minP

while True:
  if A[tar] > minC:
    count += 1
    A[tar] -= minC
  else:
    tar += 1
    minC += 1
  if tar == N:
    break

print count

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
costs = []
for x in range(N):
    costs.append(int(raw_input()))
mini = 1
n = 0
sold = 0
while n < N:
    if costs[n] <= mini:
        mini = max(mini, costs[n] + 1)
        n += 1
    elif costs[n] - mini == mini:
        costs[n] -= mini + 1
        n += 1
    else:
        costs[n] -= mini
        sold += 1
print sold

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[0]*N
for i in range(N):
    a[i]=int(input())
minimum=1
count=0
for i in  a:
   if(minimum<i):
       if i%minimum:
           count+= i//minimum
       else :
           count+= (i//minimum-1)
   else:
       minimum=max(minimum,i+1)
print(count)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
costs = []
for x in range(N):
    costs.append(int(raw_input()))
mini = 1
sold = 0
while costs != []:
    if costs[0] <= mini:
        mini = max(mini, costs[0])
        costs = costs[1:]
    else:
        costs[0] -= mini + 1
        sold += 1
print sold

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3


def main():
    n = int(input())
    xs = [int(input()) for _ in range(n)]
    ans = 0
    if xs[0] > 1:
        ans += xs[0] - 1
        xs[0] = 1
    while True:
        for i in range(n):
            if xs[i] > 2:
                xs[i] -= 4
                ans += 1
                break
        else:
            print(xs)
            print(ans)
            break


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
num=input()
a=[]
for i in range(num):
    p=input()
    a.append(p)
print a
ans=a[0]-1
a.pop(0)
nowprice=1
for custom in a:
    if (custom>nowprice+1):
        if custom % (nowprice+1)==0:
            ans += custom / (nowprice + 1)-1
        else:
            ans+=custom/(nowprice+1)
    if (custom==nowprice+1):
        nowprice+=1
print ans

Submission status: Wrong Answer

Solution code:
N =int(input())

A = [int(input()) for _ in range(N)]



def solve(target,min_n):
    if A[target] > min_n:
        return (((A[target]-1)//min_n),max(min_n,2))
    else:
        return (0, A[target]+1)

ans =0
min_n=1
for i in range(N):
    res =solve(i,min_n)
    #print(res)
    min_n = res[1]
    ans +=res[0]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [None]*n
for i in range(n):
    a[i] = int(input())
ans = a[0]-1
prev = 1
for i,num in enumerate(a[1:]):
    if prev+1<num:
        while num-(prev+1)>0:
            num -= (prev+1)
            ans += 1
            if num==prev+1:
                num = prev
                break
    prev = max(prev, num)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = []
for _ in range(N):
  A.append(int(input()))
  
cnt = A[0] - 1
cant_use = 1
for a in A[1:]:
  wk = a
  if wk == cant_use+1:
    #cnt += 1
    cant_use += 1
    continue
    
  while wk > cant_use:
    if wk % (cant_use+1) == 0:
      wk -= cant_use + 2
    else:
      wk -= cant_use + 1
    cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
cnt = 0
if A[0]>1:
    cnt += A[0]-1
    A[0]=1
cur = 1
for i in range(1,N):
    if A[i]<=cur:continue
    if A[i]==cur+1:
        cur += 1
        continue
    a = A[i]
    while True:
        if a-(cur+1)>cur+1:
            a -= (cur+1)
            cnt += 1
        elif a-(cur+1)<=cur+1:
            a -= (a-1)
            cnt += 1
            break
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(raw_input().strip())
A = [int(raw_input().strip()) for i in xrange(N)]

minP = 1
count = 0
tar = 0
minC = minP

flag = True
while flag:
  if A[tar] > minC:
    count += 1
    A[tar] -= minC
  else:
    tar += 1
    if tar == N:
      flag = False
    if A[tar] == minC:
      minC += 1
    else:
      minC += 0
  if tar == N:
    flag = False

print count

Submission status: Time Limit Exceeded

Solution code:
N = int(raw_input())
costs = []
for x in range(N):
    costs.append(int(raw_input()))
mini = 1
n = 0
sold = 0
while n < N:
    if costs[n] <= mini:
        mini = max(mini, costs[n] + 1)
        n += 1
    else:
        new = costs[n] - mini
        if mini > 1 and new == mini:
            costs[n] = new - 1
            sold += 1
            n += 1
        else:
            costs[n] = new
            sold += 1
print sold

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# get a integer
n = int(raw_input())

ls = []
for i in range(n):
    ls.append(int(raw_input()))

min = 1
cnt = 0
running = True
while running:
    for idx, i in enumerate(ls):
        if i - min > 0 and i - min is not min:
            ls[idx] -= min
            cnt += 1
            break
        elif i - min is min:
            if i - min - 1 > 0:
                ls[idx] -= min + 1
                cnt += 1
                break
            else:
                ls = ls[:idx] + ls[idx+1:]
                cnt += 1
                min += 1
                break
        elif i is min:
            ls = ls[:idx] + ls[idx+1:]
            min += 1
            break
        if idx is len(ls) - 1 and i <= min:
            running = False

#output
print cnt

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=[]
for i in range(N):
    a.append(int(input()))

minimum=1
count=0
while a:
   if(minimum<a[0]):
       if a[0]%minimum:
           count+= a[0]//minimum
           a[0]-= a[0]//minimum*minimum
       else :
           count+= (a[0]//minimum-1)
           a[0]= 1
   else:
       minimum=max(minimum,a[0]+1)
       a.pop(0)
print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys

n = int(input())

ai = []
for i in range(0, n):
    ai.append(int(input()))

count = 0
iter = 0
r = 1

if len(ai) == 1:
    print(ai[0] - 1)
    sys.exit()

while True:
    if iter == 0 and ai[0] > 1:
        ai[0] -= 1
        count += 1
    else:
        while ai[iter] <= r + 1:
            r = max(r, ai[iter])
            iter += 1
            if iter >= len(ai):
                print(count)
                sys.exit()
        if ai[iter] - (r + 1) == r + 1:
            ai[iter] = 1
            count += 1
        else:
            ai[iter] -= r + 1
            count += 1

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# get a integer
n = int(raw_input())

ls = []
for i in range(n):
    ls.append(int(raw_input()))

min = 1
cnt = 0
running = True
while running:
    for idx, i in enumerate(ls):
        if i - min > 0 and i - min is not min:
            ls[idx] -= min
            cnt += 1
            break
        elif i - min is min:
            if i - min - 1 > 0:
                ls[idx] -= min + 1
                cnt += 1
                break
            else:
                ls[idx] -= min
                cnt += 1
                min += 1
                break
        elif i is min:
            min += 1
        if idx is len(ls) - 1 and i <= min:
            running = False

#output
print cnt

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=[]
for i in range(N):
    a.append(int(input()))
minimum=1
count=0
while a:
   if(minimum<a[0]):
       count+=1
       if a[0] <= (minimum * 2) :
           a[0]=1
       else :
           a[0]-= minimum
   else:
       minimum=max(minimum,a[0]+1)
       a.pop(0)
print(count)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [int(input()) for _ in range(N)]

ans = A[0] - 1
p = 2

i = 1
while i < N:
    a = A[i]
    if a == p:
        p += 1
    else:
        ans += (a - 1) // p
    i += 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
count = 0
cur = 1
for i in range(N):
    if A[i] > cur:
        count += (A[i]-1)//cur
    elif A[i] == cur:
        cur += 1
    if cur == 1:
        cur += 1
print(count)

Submission status: Accepted

Solution code:
n=int(input())
a=[int(input()) for _ in range(n)]
def main(n,a):
  pre=0
  ans=0
  for x in a:
    if pre+2<=x:
      # pre+1以上の数値を何回か引き算してxを1以上pre以下にする
      # 引き算の回数はなるべく多く
      if x%(pre+1)==0:
        tmp=x//(pre+1)
        ans+=tmp-1
        pre=max(pre,1)
      else:
        tmp=x//(pre+1)
        ans+=tmp
        pre=max(pre,x%(pre+1))
    else:
      pre=max(pre,x)
  print(ans)
main(n,a)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]
ans = a[0] - 1
max_before = 1
for i in range(1, n):
    if a[i] <= max_before:
        continue
    elif a[i] == max_before + 1:
        max_before += 1
    else:
        ans += (a[i] - 1) // (max_before + 1)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
A = [int(input()) for _ in range(n)]
ans = A[0] - 1
tmp = 1
for a in A[1:]:
    if a <= tmp:
        pass
    elif a - 1 == tmp:
        tmp = a
    else:
        ans += (a - 1) // (tmp + 1)
print(ans)

Submission status: Accepted

Solution code:
I,A=input,int
n=A(I())
a=[A(I())for i in range(n)]
L,C=a[0]-1,2
for i in a[1:]:
 if i==C:C+=1
 L+=(i-1)//C
print(L)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())

    first = int(readline())

    ans = first - 1
    p_max = 1

    for _ in range(N - 1):
        cur = int(readline())
        if cur <= p_max:
            continue
        if cur == p_max + 1:
            p_max = cur
        else:
            ans += (cur - 1) // (p_max + 1)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
p = int(input())
ans = p - 1
bottom = 1
for _ in range(N-1):
    p = int(input())
    if p == bottom + 1:
        bottom += 1
    elif p % (bottom+1) == 0:
        ans += p // (bottom+1) - 1
    else:
        ans += p // (bottom+1)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
A=[int(input()) for ii in range(n)]

ans=A[0]-1
now=2
for i in range(1,n):
    if A[i]==now:
        now+=1;continue
    ans+= (A[i]-1)//now
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]
cur = 1
ans = A[0] - 1
for a in A[1:]:
    if a == cur + 1:
        cur += 1
    elif a % (cur + 1) == 0:
        ans += a // (cur + 1) - 1
    else:
        ans += a // (cur + 1)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=[]
for i in range(n):
        a=int(input())
        l.append(a)

ans=l[0]-1
nowmin=2
for i in range(1,n):
        if l[i] == nowmin:
                nowmin+=1
                continue
        if l[i]%nowmin==0:
                l[i]-=(nowmin+1)
                ans+=1
        ans += l[i]//nowmin
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
curr_max = 0
ans = 0
for i in range(n):
    a = int(input())
    if i == 0:
        ans += (a-1)
        curr_max = 1
    else:
        step = curr_max + 1
        if a > step: 
            diff = a - 1
            ans += diff//step
        else:
            curr_max = max(a, curr_max)
            # print(i, curr_max)

print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
ans = 0
for i in range(N):
    a = int(input())
    if i==0:
        base = 2
        ans += a-1
        continue
    if a<base:
        continue
    if a==base:
        base+=1
    elif a%base==0:
        ans += (a-1)//base
    else:
        ans += a//base
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
alst = [int(input()) for _ in range(n)]
ans = alst[0] - 1
price = 2
max_p = 2
for a in alst[1:]:
    if a > price:
        ans += (a - 1) // price
    elif max_p == a:
        max_p += 1
        price += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=[int(input()) for _ in range(n)]
mi=1
ans=a[0]-1
for x in a[1:]:
  if x>mi+1:
    ans+=(x-1)//(mi+1)
  else:
    mi=max(mi,x)
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=[int(input()) for i in range(N)]
P=0
X=1
for i in range(N):
  P+=(A[i]-1)//X
  if A[i]==X or X==1:
    X+=1
print(P)

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [None]*n
for i in range(n):
    a[i] = int(input())
ans = a[0]-1
prev = 1
for i,num in enumerate(a[1:]):
    if prev+1<num:
        while num-(prev+1)>0:
            v = (num-1)//(prev+1)
            num -= v*(prev+1)
            ans += v
            if num==prev+1:
                num = prev
                break
    prev = max(prev, num)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = []
for _ in range(N):
  A.append(int(input()))
  
cnt = A[0] - 1
cant_use = 1
for a in A[1:]:
  wk = a
  if wk == cant_use+1:
    #cnt += 1
    cant_use += 1
    continue
    
  if wk % (cant_use+1) == 0:
    wk -= cant_use + 2
    cnt += 1
  cnt += wk // (cant_use+1)
print(cnt)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    A = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    cur=1
    ans=0
    for i,a in enumerate(A):
        if i==0:
            ans+=a-1
            cur=2
            continue
        if a==cur:
            cur+=1
            continue
        d,x=divmod(a,cur)
        if x==0:
            a-=cur+1

            ans+=a//cur+1
        else:
            ans+=d

    print(ans)


        
        




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

n = readint()
a = [readint() for i in range(n)]

ans = a[0]-1
p = 2

for i in range(1,n):
    if a[i]%p==0:
        ans += a[i]//p-1
        if a[i] == p:
            p+=1
    else:
        ans += a[i]//p

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)

N = ini()
A = [ini() for _ in range(N)]


def solve():
    p_min = 1
    ans = 0
    # debug(A)
    for i in range(N):
        if A[i] < p_min:
            continue
        if A[i] == p_min:
            p_min += 1
            continue
        k = (A[i] - 1) // p_min
        ans += k
        A[i] = 1
        if p_min == 1:
            p_min += 1
        # debug(f">> {i=} {p_min=} {k=} {ans=} {A=}")
    return ans


print(solve())

Submission status: Accepted

Solution code:
N = int(input())

min_P = 1
ans = 0
for _ in range(N):
    A = int(input())
    if A == min_P:
        min_P += 1
    else:
        ans += (A - 1) // min_P
        if min_P == 1:
            min_P += 1

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
f=1
ans=0
for _ in range(n):
  a=int(input())
  m=(a-1)//f
  ans+=m
  a-=m*f
  if m:a=1
  f=max(f,a+1)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
*A, = [int(input()) for _ in range(N)]

ans = 0
v = 1

for i, j in enumerate(A):
    if i==0:
        ans += j-1
    else:
        if j==v+1:
            v += 1
        ans += (j-1)//(v+1)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]

ans = 0
tmp = 1
for i in range(n):
    if a[i] > tmp:
        ans += (a[i] - 1) // tmp
        a[i] = 1

    tmp = max(tmp, a[i] + 1)

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
A = [int(input()) for i in range(n)]

t = 1
ans = 0
for i in range(n):
    if A[i] == t:
        t += 1
    elif A[i] % t == 0:
        ans += (A[i]-1) // t
    else:
        ans += A[i] // t
    if t == 1:
        t += 1
    # print(ans)
print(ans)

Submission status: Accepted

Solution code:
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
n=N()
l=LN(n)
ans=l[0]-1
lo=2
for i in l[1:]:
    if i==lo:
        lo+=1
    else:
        ans+=(i-1)//lo
print(ans)

Submission status: Accepted

Solution code:
#greedy customers
N=int(input())
ans=0
d=[int(input()) for _ in range(N)]
if d[0]>1:
    ans+=d[0]-1
d[0]=1
now=2
for i in range(1,N):
    if d[i]==now:
        now+=1
    else:
        #d[i]!=now:
        if d[i]<now:
            pass
        elif d[i]>now:
            if d[i]%now==0:
                K=d[i]//now
                if K==2:
                    ans+=1
                    d[i]=1
                elif K>2:
                    ans+=K-1
                    d[i]=1                
            elif d[i]%now!=0:
                u,v=divmod(d[i],now)
                ans+=u
                d[i]=v
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]
ans = A[0] - 1
P = 2
for i in range(1, N):
    if A[i] == P:
        P += 1
        continue
    ans += (A[i]-  1) // P
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
cur = 1
ans = 0
for i in a:
  num = (i - 1) // cur
  ans += num
  i -= cur * num
  if cur != i or i == 1 or num == 0:
  	cur = max(cur,i+1)
  #print(i,num,cur)
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline

def main():
	N = int(input())
	
	ans = 0
	a1 = int(input())
	ans += a1-1

	base = 2
	for _ in range(N-1):
		a = int(input())
		if a < base:
			continue
		elif a == base:
			base += 1
		else:
			ans += (a-base-1)//base+1
	
	print(ans)

if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
n = int(input())
m = 1
ans = int(input()) - 1
for _  in range(n-1):
  a = int(input())
  if a == m+1:
    m += 1
  else:
    ans += (a-1)//(m+1)
print(ans)

Submission status: Accepted

Solution code:
import sys

input=sys.stdin.readline

N=int(input())
ans=0
val=2
for i in range(N):
    a=int(input())
    if i==0:
        ans+=a-1
        val=2
    else:
        if a!=val:
            ans+=(a-1)//val
        else:
            val+=1

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
ans=0
val=2
for i in range(N):
    a=int(input())
    if i==0:
        ans+=a-1
        val=2
    else:
        if a!=val:
            ans+=(a-1)//val
        else:
            val+=1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = int(input())
ans = 0
ans += a-1
minim = 2
for ii in range(n-1):
    a = int(input())
    i = ii+1
    if(a==minim):
        minim+=1
    else:
        ans+=(a-1)//minim

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
M = 0
ans = 0
for i in range(n):
    a = int(input())
    if M == 0:
        ans += a-1
        M = 1
    elif a <= M+1:
        M = max(M,a)
    else:
        ans += (a-1)//(M+1)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a0 = int(input())

rem = 1
res = a0 - 1

for _ in range(N - 1):
    a = int(input())
    if a >= rem + 2:
        res += (a - 1) // (rem + 1)
    elif a == rem + 1:
        rem = a
    else:
        pass

print(res)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, *A = map(int, read().split())
if N == 1:
    print(A[0] - 1)
    exit()

answer = A[0] - 1
P = 2
for i in A[1:]:
    if i < P:
        continue
    elif i == P:
        P += 1
        continue
    answer += (i - 1) // P

print(answer)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]

ans = A[0] - 1
min_a = 1
for a in A[1:]:
  p = min_a + 1
  if a % p:
    ans += a // p
  else:
    diff = a//p - 1
    if diff:
      ans += diff
    else:
      min_a = a

print(ans)

Submission status: Accepted

Solution code:
import sys

n, *aaa = map(int, sys.stdin.buffer.read().split())

ans = aaa[0] - 1
min_p = 2
for a in aaa[1:]:
    if a == min_p:
        min_p += 1
        continue
    d, m = divmod(a, min_p)
    if m == 0:
        d -= 1
    ans += d
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST(N)

lim = 1
ans = 0
for a in A:
    d, m = divmod(a, lim)
    if d == 0 or d == 1 and m == 0:
        lim = max(lim, a+1)
    else:
        ans += d - (m == 0)
        lim = max(lim, 2)
print(ans)

Submission status: Accepted

Solution code:
N,*A = map(int, open(0).read().split())
p = 1
ans = 0
for c in A:
  if c%p!=0:
    ans += c//p
  else:
    if c==p:
      p += 1
      continue
    ans += c//p-1
    if p==1:
      p += 1
print(ans)

Submission status: Accepted

Solution code:
#import decimal
#decimal.getcontext().prec==500 Floatの桁数を500まで増やす
#Decimal(c).sqrt() それで平方根を求める
#Decimal(1) / Decimal(7) 1/7
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math
from fractions import gcd
import sys
#input = sys.stdin.readline


#N=int(input())

N=int(input())
A=[int(input()) for i in range(N)]
count=A[0]-1
m=1
for i in range(1,N):
    z=(A[i]-1)//(m+1)
    count+=z
    if not z:
        m=max(m,A[i])
    #print(m,z,A[i])
print(count)

Submission status: Accepted

Solution code:
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = int(input())

ans = A[0]-1
tmp = 2
for i in range(1, N):
    if A[i] == tmp:
        tmp += 1
    elif A[i] > tmp:
        ans += (A[i]-1)//tmp

print(ans)

Submission status: Accepted

Solution code:
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = []
for i in range(n):
    a.append(inn())
sm = a[0]-1
px = 1
#ddprint(f"i {0} inc {0} sm {sm} px {px}")
for i in range(1,n):
    #if px==1:
    #    inc = a[i]-px-1
    #else:
    inc = (a[i]-px)//(px+1) + (1 if (a[i]-px)%(px+1)>=2 else 0)
    sm += inc
    if a[i]==px+1:
        px += 1
    #ddprint(f"i {i} inc {inc} sm {sm} px {px}")
print(sm)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
As = [int(input()) for _ in range(N)]

ans = As[0]-1
M = 1
for A in As[1:]:
    if A == M+1:
        M += 1
    else:
        if A > M+1:
            ans += (A-(M+2))//(M+1) + 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = [ int(input()) for _ in range(N) ]

ans =  0
m = 1
for i,a in enumerate(A):
  if i == 0:
    ans += a-1
    m = 1
  elif a == m+1:
    m = m + 1
  else:
    ans += (a - 1) // (m+1)
print(ans)

Submission status: Accepted

Solution code:
def main():
	n, *a = map(int, open(0).read().split())
	cur = 1
	ans = a[0] - 1
	a[0] = 1
	for x in a:
		if x <= cur:
			pass
		elif x == cur + 1:
			cur = x
		else:
			ans += 0 - -(x - cur - 1) // (cur + 1)
	print(ans)

if __name__=="__main__":
	main()