Problem:


Score : 500 points

Problem Statement

There are N boxes arranged in a circle. The i-th box contains A_i stones.

Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:

Select one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.

Note that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.

Constraints

1 ≦ N ≦ 10^5

1 ≦ A_i ≦ 10^9

Input

The input is given from Standard Input in the following format:

N
A_1 A_2 … A_N

Output

If it is possible to remove all the stones from the boxes, print YES. Otherwise, print NO.

Sample Input 1

5
4 5 1 2 3

Sample Output 1

YES

All the stones can be removed in one operation by selecting the second box.

Sample Input 2

5
6 9 12 10 8

Sample Output 2

YES

Sample Input 3

4
1 2 3 1

Sample Output 3

NO



Sample input:
5
4 5 1 2 3


Sample output:
YES

Submission status: Wrong Answer

Solution code:
import math
def solve():
    n=int(input())
    a=list(map(int, input().split()))
    tmp=0
    if n==1:
        return 'YES'
    for i in range(n-1):
        if a[i]>(a[i+1]+tmp*n):
            tmp=math.ceil((a[i]-a[i+1])/n)
        a[i+1]+=tmp*n
    tmp = a[1]-a[0]
    if all(a[i+1]-a[i]==tmp for i in range(1, n-1)) and tmp<a[0]:
        return 'YES'
    else:
        return 'NO'
print(solve())

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
N=((n)*(n+1))//2

if sum(A)%N!=0:
    print("NO")
    exit()
else:
    T=(sum(A)//N)
    A+=[A[0]]
    cnt=0
    for i in range(1,len(A)):
        if (A[i]-A[i-1])==T:
            #print(A[i],A[i-1])
            continue
        else:
            if A[i-1]>A[i]-T:
                B=((A[i-1]-A[i])//n)+1
                cnt+=B
                #print(A[i],A[i-1],n*B)
                if (A[i]-A[i-1]+n*B)==T:
                    continue
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
    if T==cnt:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
N=((n)*(n+1))//2

if sum(A)%N!=0:
    print("NO")
    exit()
elif n==1:
    print("YES")
elif n==2:
    if max(A[1],A[0])-min(A[1],A[0])<=max(A[1],A[0])/2:
        print("YES")
        exit()
    else:
        print("NO")
        exit()
else:
    T=(sum(A)//N)
    A+=[A[0]]
    cnt=0
    for i in range(1,len(A)):
        if (A[i]-A[i-1])==T:
            #print(A[i],A[i-1])
            continue
        else:
            if A[i-1]>A[i]-T:
                B=((A[i-1]-A[i])//n)+1
                cnt+=B
                print(A[i],A[i-1],n*B)
                if (A[i]-A[i-1]+n*B)==T:
                    continue
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
    if T==cnt:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
N=((n)*(n+1))//2

if sum(A)%N!=0:
    print("NO")
    exit()
elif n==1:
    print("YES")
elif n==2:
    if (A[1]+A[0])%3==0:
        print("YES")
        exit()
    else:
        print("NO")
        exit()
else:
    T=(sum(A)//N)
    A+=[A[0]]
    cnt=0
    for i in range(1,len(A)):
        if (A[i]-A[i-1])==T:
            #print(A[i],A[i-1])
            continue
        else:
            if A[i-1]>A[i]-T:
                B=((A[i-1]-A[i])//n)+1
                cnt+=B
                print(A[i],A[i-1],n*B)
                if (A[i]-A[i-1]+n*B)==T:
                    continue
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
    if T==cnt:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
N=((n)*(n+1))//2

if sum(A)%N!=0:
    print("NO")
    exit()
elif n==1:
    print("YES")
elif n==2:
    print("YES")
else:
    T=(sum(A)//N)
    A+=[A[0]]
    cnt=0
    for i in range(1,len(A)):
        if (A[i]-A[i-1])==T:
            #print(A[i],A[i-1])
            continue
        else:
            if A[i-1]>A[i]-T:
                B=((A[i-1]-A[i])//n)+1
                cnt+=B
                print(A[i],A[i-1],n*B)
                if (A[i]-A[i-1]+n*B)==T:
                    continue
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
    if T==cnt:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
N=((n)*(n+1))//2

if sum(A)%N!=0:
    print("NO")
    exit()
elif n==1:
    print("YES")
else:
    T=(sum(A)//N)
    A+=[A[0]]
    cnt=0
    for i in range(1,len(A)):
        if (A[i]-A[i-1])==T:
            #print(A[i],A[i-1])
            continue
        else:
            if A[i-1]>A[i]-T:
                B=((A[i-1]-A[i])//n)+1
                cnt+=B
                #print(A[i],A[i-1],n*B)
                if (A[i]-A[i-1]+n*B)==T:
                    continue
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
    if T==cnt:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
N=((n)*(n+1))//2

if sum(A)%N!=0:
    print("NO")
    exit()
else:
    T=(sum(A)//N)
    A+=[A[0]]
    cnt=0
    for i in range(1,len(A)):
        if (A[i]-A[i-1])==T:
            #print(A[i],A[i-1])
            continue
        else:
            if A[i-1]>A[i]-T:
                B=((A[i-1]-A[i])//n)+1
                cnt+=B
                #print(A[i],A[i-1],n*B)
                if (A[i]-A[i-1]+n*B)==T:
                    continue
                else:
                    print("NO")
                    exit()
            else:
                print("NO")
                exit()
    if T==cnt:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
N=((n)*(n+1))//2

if sum(A)%N!=0:
    print("NO")
    exit()
else:
    T=(sum(A)//N)
    A+=[A[0]]
    cnt=0
    for i in range(1,len(A)):
        if (A[i]-A[i-1])==T:
            #print(A[i],A[i-1])
            continue
        else:
            if A[i-1]>A[i]:
                B=((A[i-1]-A[i])//n)+1
                cnt+=B
                #print(A[i],A[i-1],n*B)
                if (A[i]-A[i-1]+n*B)==T:
                    continue
                else:
                    print("NO")
                    exit()
            else:
                cnt+=((A[i]-A[i-1]-T)//n)
    if T==cnt:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
A=[int(i) for i in input().split()]
if sum(A)%((N*(N+1))//2)!=0:
    print('NO')
    sys.exit()
k=sum(A)//((N*(N+1))//2)
B=[0]*N
for i in range(N):
    B[i]=A[i]-A[i-1]
for a in B:
    if a-k<0 and (k-a)%N==0:
        continue
    print('NO')
    sys.exit()
print('YES')

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
A=[int(i) for i in input().split()]
if sum(A)%((N*(N+1))//2)!=0:
    print('NO')
    sys.exit()
k=sum(A)//((N*(N+1))//2)
for a in A:
    if a-k<0 and (k-a)%N==0:
        continue
    print('NO')
    sys.exit()
print('YES')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

s = sum(a)

if s%(n*(n+1)//2)!=0:
    print('NO')
    exit()

ss = s//(n*(n+1)//2)

b = [0 for i in range(n)]

# a[i]-a[i-1] = ss-b[i-1]*n
for i in range(n):
    b[i-1] = (ss-a[i]+a[i-1])//n
    if b[i-1]<0:
        print('NO')
        exit()

c = [0 for i in range(n)]
for i in range(n):
    c[0]+=b[i]*(n-i)

for i in range(1,n):
    c[i] = c[i-1] + ss - b[i-1]*n

if a==c:
    print('YES')
else:
    print('NO')

print(b)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

s = sum(a)

if s%(n*(n+1)//2)!=0:
    print('NO')
    exit()

ss = s//(n*(n+1)//2)

b = [0 for i in range(n)]

for i in range(n):
    b[i-1] = (ss-a[i]+a[i-1])//n

c = [0 for i in range(n)]
for i in range(n):
    c[0]+=b[i]*(n-i)

for i in range(1,n):
    c[i] = c[i-1] + ss - b[i-1]*n

if a==c:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

s = sum(a)

if s%n!=0:
    print('NO')
    exit()

ss = s//(n*(n+1)//2)

b = [0 for i in range(n)]

# a[i]-a[i-1] = ss-b[i-1]*n
for i in range(n):
    b[i-1] = (ss-a[i]+a[i-1])//n

c = [0 for i in range(n)]
for i in range(n):
    c[0]+=b[i]*(n-i)

for i in range(1,n):
    c[i] = c[i-1] + ss - b[i-1]*n

if a==c:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
a = list(map(int, input().split()))

s = [0 for i in range(n)]

for i in range(n):
    if a[i-1]>a[i]:
        s[i-1] = math.ceil((a[i-1]-a[i])/(n-1))

ss = sum(s)
b = [0 for i in range(n)]
for i in range(n):
    b[0]+=s[i]*(n-i)

for i in range(1,n):
    b[i] = b[i-1] + ss - s[i-1]*n

if b==a:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    k = sum(A)//(N*(N+1)//2)
    if sum(A) % (N*(N+1)//2) != 0 or True:
        return "NO"

    D = [0]*N
    for i in range(N-1):
        D[i] = A[i+1]-A[i]-k
    D[-1] = A[0]-A[-1]-k

    cnt = sum([v//N for v in D])
    if all(x <= 0 and -x % N == 0 for x in D)and -cnt == k:
        return "YES"
    else:
        return "NO"


print(solve())

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
k = sum(A)//(N*(N+1)//2)
ans = "NO"
if sum(A) % (N*(N+1))//2 != 0:
    ans = "NO"

cnt = 0
for i in range(N):
    diff = A[i]-A[i-1]
    if diff == k:
        continue
    if -1 * (diff-k) % N != 0:
        ans = "NO"
        break
    c = -(diff-k)//N
    if c < 0:
        ans = "NO"
        break
    cnt += c
if cnt == k:
    ans = "YES"
print(ans)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

k = sum(A)//(N*(N+1)//2)
D = [0]*N
for i in range(N-1):
    D[i] = A[i+1]-A[i]
D[-1] = A[0]-A[-1]

for i in range(N):
    D[i] -= k

cnt = sum([v//N for v in D])
if all(x <= 0 and x % N == 0 for x in D)and -cnt == k:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

k = sum(A)//(N*(N+1)//2)
D = [0]*N
for i in range(N-1):
    D[i] = A[i+1]-A[i]
D[-1] = A[0]-A[-1]

for i in range(N):
    D[i] -= k

if all(x <= 0 and x % N == 0 for x in D):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
sa = sum(a)
stone = n*(n+1)//2
if sa % stone:
    print("NO")
    exit()
a.append(a[0])
k = sa//stone
d = [a[i+1]-a[i] - k for i in range(n)]
for i in d:
    if i%n:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
sa = sum(a)
stone = n*(n+1)//2
if sa % stone:
    print("No")
    exit()
a.append(a[0])
k = sa//stone
d = [a[i+1]-a[i] - k for i in range(n)]
for i in d:
    if i%n:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
def s():
  pass

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
tot = sum(a)
f = tot*2 // ((n+1)*n)
l = [0]*n
for i in range(n-1):
  l[i] = a[i+1] - a[i] - f
l[-1] = a[0] - a[n-1] - f
for x in l:
  if x > 0 or x%n:
    print("NO")
    break
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
S = sum(A)
last = A[-1]
for i in reversed(range(1, N)):
    A[i] -= A[i-1]
A[0] -= last

T = (N*N+N)//2

ans = "YES"
if S % T != 0 or sum(A) != 0:
    ans = "NO"
else:
    t = S//T
    if any(a % N != A[0] % N for a in A):
        ans = "NO"
    if sum(a//5 for a in A) != -((t) % N):
        ans = "NO"
print(ans)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
S = sum(A)
last = A[-1]
for i in reversed(range(1, N)):
    A[i] -= A[i-1]
A[0] -= last

T = (N*N+N)//2

ans = "YES"
if S % T != 0 or sum(A) != 0:
    ans = "NO"
else:
    t = S//T
    A = list(map(lambda x: x % N, A))
    if any(a != A[0] for a in A):
        ans = "NO"
    if sum(a//5 for a in A) != -((t-1) % N):
        print(list(a//5 for a in A))
        ans = "NO"
print(ans)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
S = sum(A)
last = A[-1]
for i in reversed(range(1, N)):
    A[i] -= A[i-1]
A[0] -= last

T = (N*N+N)//2

ans = "YES"
if S % T != 0 or sum(A) != 0:
    ans = "NO"
else:
    t = S//T
    A = list(map(lambda x: x % N, A))
    if any(a != A[0] for a in A):
        ans = "NO"
    if sum(a//5 for a in A) != -(t % N):
        ans = "NO"
print(ans)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
S = sum(A)
last = A[-1]
for i in reversed(range(1, N)):
    A[i] -= A[i-1]
A[0] -= last


ans = "YES"
if S % N != 0 or sum(A) != 0:
    ans = "NO"
else:
    t = S//N
    A = list(map(lambda x: x % N, A))
    if any(a != A[0] for a in A):
        ans = "NO"
    if sum(a//5 for a in A) != -(t % N):
        ans = "NO"
print(ans)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
S = sum(A)
last = A[-1]
for i in reversed(range(1, N)):
    A[i] -= A[i-1]
A[0] -= last


ans = "YES"
if S % N != 0 or sum(A) != 0:
    ans = "NO"
else:
    t = S//N
    A = list(map(lambda x: x % N, A))
    if any(a != A[0] for a in A):
        ans = "NO"
    if sum(a//5 for a in A) != -t:
        ans = "NO"
print(ans)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
S = sum(A)
last = A[-1]
for i in reversed(range(1, N)):
    A[i] -= A[i-1]
A[0] -= last


ans = "YES"
if S % N != 0 or sum(A) != 0:
    ans = "NO"
else:
    t = S//N
    A = list(map(lambda x: x % N, A))
    if any(a != A[0] for a in A):
        ans = "NO"
print(ans)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
S = sum(A)
last = A[-1]
for i in reversed(range(1, N)):
    A[i] -= A[i-1]
A[0] -= last


ans = "YES"
if S % N != 0:
    ans = "NO"
else:
    t = S//N
    A = list(map(lambda x: x % N, A))
    if any(a != A[0] for a in A):
        ans = "NO"
print(ans)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
S = sum(A)
last = A[-1]
for i in reversed(range(1, N)):
    A[i] -= A[i-1]
A[0] -= last

if S % N == 0 and sum(A) == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
S = sum(A)
last = A[-1]
for i in reversed(range(1, N)):
    A[i] -= A[i-1]
A[0] -= last

print(A)
if S % N == 0 and sum(A) == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))

def solve():
    q = N * (N + 1) // 2
    if sum(A) % q:
        print('NO')
        return
    times = sum(A) // q
    cnt = 0
    for i, j in zip(A, A[1:] + [A[0]]):
        dif = times + i - j
        if dif % N:
            print('NO')
            return
        cnt += dif // N
    if times == cnt:
        print('YES')
    else:
        print('NO')

solve()

Submission status: Wrong Answer

Solution code:
# from random import randrange
#
# def rotate(arr, n):
#     return arr[n:] + arr[:n]
#
# N = 10
# M = 7
# arr = [i + 1 for i in range(N)]
#
# ret = [0] * N
# for i in range(M):
#     rnd = randrange(N)
#     for j, k in enumerate(rotate(arr, rnd)):
#         ret[j] += k
#
# print(ret)

N = int(input())
ret = list(map(int,input().split()))

A = ret[0]
for i in range(N):
    ret[i] -= (i + 1) * A

# print(ret)
l = [(i - j) % N for i, j in zip(ret, ret[1:])]

print('YES' if all(l[0] == i for i in l) else 'NO')

Submission status: Wrong Answer

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

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	ret_ng='NO'
	ret_ok='YES'
	return ret_ng
	
	n=int(io())
	l= list(map(int, io().split()))
	
	v_one_act =n*(n+1)/2
	
	if sum(l)%v_one_act != 0:
		return ret_ng
		
	act_num=sum(l)//v_one_act	
	st_num=0
	
	for a,b in zip(l, l[1:]+l):
		diff = b - a
		if (act_num-diff)%(n)!=0:
			return ret_ng
		if (act_num-diff)<0:
			return ret_ng
		st= (act_num-diff)//(n)
		st_num+=st
	
	if act_num!=st_num:
		return ret_ng
		
	
		
	return ret_ok

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Submission status: Wrong Answer

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

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	ret_ng='NO'
	ret_ok='YES'
	return ret_ng
	
	n=int(io())
	l= list(map(int, io().split()))
	
	v_one_act =n*(n+1)/2
	
	if sum(l)%v_one_act != 0:
		return ret_ng
		
	act_num=sum(l)//v_one_act	
	st_num=0
	for a,b in zip(l, l[1:]+l):
		diff = b - a
		if (diff - act_num)%(n)!=0:
			return ret_ng
		st=-1*(diff-act_num)//(n)
		st_num+=st
	
	#if act_num!=st_num:
	#	return ret_ng
		
	return ret_ok

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Submission status: Wrong Answer

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

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	ret_ng='NO'
	ret_ok='YES'
	
	n=int(io())
	l= list(map(int, io().split()))
	
	v_one_act =n*(n+1)/2
	
	if sum(l)%v_one_act != 0:
		return ret_ng
		
	act_num=sum(l)//v_one_act	
	st_num=0
	for a,b in zip(l, l[1:]+l):
		diff = b - a
		if (diff - act_num)%(n)!=0:
			return ret_ng
		st=-1*(diff-act_num)//(n)
		st_num+=st
	
	#if act_num!=st_num:
	#	return ret_ng
		
	return ret_ok

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
 
sum_a = sum(a)
len_a = len(a)
kaisu = sum_a / ( (1/2)*(len_a)*(len_a+1) )
 
if kaisu != int(kaisu):
  print("NO")
  exit()
  
kaisu = int(kaisu)
ans_kaisu = 0
for i in range(n-1):
  tmp = (kaisu - (a[i+1]-a[i])) / len_a
  if tmp != int(tmp):
    print("NO")
    exit()
  ans_kaisu += (kaisu - (a[i+1]-a[i])) // len_a
ans_kaisu += (kaisu - (a[0]-a[n-1])) // len_a
 
if ans_kaisu ==kaisu:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))

sum_a = sum(a)
len_a = len(a)
kaisu = sum_a / ( (1/2)*(len_a)*(len_a+1) )

if kaisu != int(kaisu):
  print("NO")
  exit()
  
kaisu = int(kaisu)
ans_kaisu = 0
for i in range(n-1):
  ans_kaisu += (kaisu - (a[i+1]-a[i])) // len_a
ans_kaisu += (kaisu - (a[0]-a[n-1])) // len_a

if ans_kaisu ==kaisu:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	ret_ng='NO'
	ret_ok='YES'
	n=int(io())
	l= list(map(int, io().split()))
	v_one_act =n*(n+1)/2
	
	if sum(l)%v_one_act != 0:
		return ret_ng
		
	act_num=sum(l)//v_one_act
		
	st_num=0
	for a,b in zip(l, l[1:]+l):
		diff = b - a
		if (diff - act_num)%(n)!=0:
			return ret_ng
		st=-1*(diff-act_num)//(n)
		st_num+=st
	
	if act_num!=st_num:
		return ret_ng
		
	return ret_ok

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    # 1. Aの総和から操作の回数が分かる
    k = sum(A) // (n * (n + 1) // 2)

    A.append(A[0])
    diff = []
    for a1, a2 in zip(A[:-1], A[1:]):
        diff.append(a2 - a1)

    # 2. 逆に石を配る操作を考える
    # 一回の操作で1つのdkは-(n - 1), それ以外は+1される

    # 3. {di - k}は負かつnの倍数になっている必要がある
    return 'YES' if not any([-(d - k) % n or d > k for d in diff]) else 'NO'


print(main())

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    # 1. Aの総和から操作の回数が分かる
    k = sum(A) // (n * (n + 1) // 2)

    A.append(A[0])
    diff = []
    for a1, a2 in zip(A[:-1], A[1:]):
        diff.append(a2 - a1)

    # 2. 逆に石を配る操作を考える
    # 一回の操作で1つのdkは-(n - 1), それ以外は+1される

    # 3. {di - k}は負かつnの倍数になっている必要がある
    return 'YES' if not any([(d - k) % n or d > k for d in diff]) else 'NO'


print(main())

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    # 1. Aの総和から操作の回数が分かる
    k = sum(A) // (n * (n + 1) // 2)

    A.append(A[0])
    diff = []
    for a1, a2 in zip(A[:-1], A[1:]):
        diff.append(a2 - a1)

    # 2. 逆に石を配る操作を考える
    # 一回の操作で1つのdkは-(n - 1), それ以外は+1される

    # 3. {di - k}は負かつnの倍数になっている必要がある
    return 'YES' if not any([(d - k) % n for d in diff]) else 'NO'


print(main())

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    A.append(A[0])
    diff = set()
    for a1, a2 in zip(A[:-1], A[1:]):
        diff.add(a1 - a2)

    return 'YES' if len(diff) <= 2 else 'NO'


print(main())

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    A.append(A[0])
    diff = set()
    for a1, a2 in zip(A[:-1], A[1:]):
        diff.add(a1 - a2)

    return 'Yes' if len(diff) <= 2 else 'NO'


print(main())

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
if sum(a) % ((1 + n) * n // 2):
    print("NO")
else:
    m = sum(a) // ((1 + n) * n // 2)
    d = [0] * n
    for i in range(n):
        d[i] = a[(i + 1) % n] - a[i] - m
    for i in d:
        if i % n:
            print("NO")
            exit()
    if -sum(d) == n * m:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
if sum(a) % ((1 + n) * n // 2):
    print("NO")
else:
    m = sum(a) // ((1 + n) * n // 2)
    d = [0] * n
    for i in range(n):
        if i == n - 1:
            d[i] = a[0] - a[i] - m
        else:
            d[i] = a[i + 1] - a[i] - m
    for i in d:
        if i % n:
            print("NO")
            exit()
    print("YES")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
m = sum(a) // ((1 + n) * n // 2)
d = [0] * n
for i in range(n):
    if i == n - 1:
        d[i] = a[0] - a[i] - m
    else:
        d[i] = a[i + 1] - a[i] - m
for i in d:
    if i % n:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
m = sum(a) // ((1 + n) * n // 2)
flag = [False] * n
for i in range(n):
    if i == n - 1:
        flag[i] = (a[0] - a[i] != m)
    else:
        flag[i] = (a[i + 1] - a[i] != m)
if sum(flag) == m:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
if sum(a) % ((n + 1) * n // 2) == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

if sum(a) % (n * (n+1) // 2) != 0:
    print("NO")
    exit()

k = sum(a) // (n * (n+1) // 2)
b = [0] * n
for i in range(n-1):
    b[i] = a[i+1] - a[i]
b[n-1] = a[0] - a[n-1]

for i in range(n):
    b[i] -= k

count = 0
for nb in b:
    if -nb % n != 0:
        print("NO")
        exit()
    count += -nb // n

if count == k:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

if sum(a) % (n * (n+1) // 2) != 0:
    print("NO")
    exit()

k = sum(a) // (n * (n+1) // 2)
b = [0] * n
for i in range(n-1):
    b[i] = a[i+1] - a[i]
b[n-1] = a[0] - a[n-1]

for i in range(n):
    b[i] -= k

count = 0
for nb in b:
    if nb != 0 and nb != -n:
        print("NO")
        exit()
    if nb == -n:
        count += 1

if count == k:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

S = N*(N+1)//2
A = [a for a in A]
D = [A[(i+1)%N] - A[i%N] for i in range(N)]
M, m = divmod(sum(A), S)

if sum(D) != 0 or m != 0:
    print("NO")
else:
    tmp = 0
    for i in range(N):
        d, m = divmod(-(D[i] - M), N)
        if m:
            print("NO")
            break
        tmp += d
    else:
        if tmp == M:
            print("YES")
        else:
            print("NO")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

S = N*(N+1)//2
A = [a for a in A]
D = [A[(i+1)%N] - A[i%N] for i in range(N)]
M, m = divmod(sum(A), S)

if sum(D) != 0 or m != 0:
    print("NO")
else:
    tmp = 0
    for i in range(N):
        d, m = divmod(-(D[i] - M), N)
        if m:
            print("NO")
            break
        tmp += d
    if tmp == M:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

S = N*(N+1)//2
A = [a%S for a in A]
D = [A[(i+1)%N] - A[i%N] for i in range(N)]
M, m = divmod(sum(A), S)

if sum(D) != 0 or m != 0:
    print("NO")
else:
    tmp = 0
    for i in range(N):
        d, m = divmod(-(D[i] - M), N)
        if m:
            print("NO")
            break
        tmp += d
    if tmp == M:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
ans='YES'
suma=sum(a)
i=suma/(n*(n+1)//2)
a2=[a[j]-a[j-1]-i for j in range(n)]
for i in a2:
    if i%n!=0:ans='NO'
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
suma=sum(a)
for i in range(10**4):
    if (n*(n+1)//2)*i==suma:break
a2=[a[j]-a[j-1]-i for j in range(n)]
ans='YES'
for i in a2:
    if i%n!=0:ans='NO'
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

one2n = sum([i for i in range(1, n+1)])

ok = True

if sum(a) % one2n > 0:
    ok = False
    
if ok:
    b = a + [a[0]]
    end = 0
    kire = sum(a) // one2n
    for idx in range(n):
        dif = b[idx+1] - b[idx]
        if (kire-dif) % n > 0:
            ok = False
            break
        
        elif not 0 <= (kire-dif)//n <= n:
            ok = False
            break
        
        end += (kire-dif) // n
        
    if end != kire:
        ok = False
        
print("YES") if ok else print("NO")

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

one2n = sum([i for i in range(1, n+1)])

ok = True

if sum(a) % one2n > 0:
    ok = False
    
if ok:
    b = a + [a[0]]
    end = 0
    kire = sum(a) // one2n
    for idx in range(n):
        dif = b[idx+1] - b[idx]
        if (kire-dif) % n > 0:
            ok = False
            break
        
        elif not 0 <= (kire-dif) <= n:
            ok = False
            break
        
        end += (kire-dif) // n
        
    if end != kire:
        ok = False
        
print("YES") if ok else print("NO")