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:
n = int(input())
a = [int(i) for i in input().split()]
if sum(a) % (n * (n + 1) // 2) != 0:
    print("NO")
    exit()
if n == 1:
    print("YES")
    exit()

k = sum(a) // (n * (n + 1) // 2)

if n == 2:
    if min(a) >= k:
        print("YES")
    else:
        print("NO")
    exit()

l = 0
for i in range(n):
    j = (i + 1) % n
    m = a[j]-a[i]
    if (m - k) % n != 0 or (m - k) // n <= 0:
        print("NO")
        exit()
    l -= (m - k) // n
if k == l:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
if sum(a) % (n * (n + 1) // 2) != 0:
    print("NO")
    exit()
if n == 1:
    print("YES")
    exit()

k = sum(a) // (n * (n + 1) // 2)

if n == 2:
    if min(a) >= k:
        print("YES")
    else:
        print("NO")
    exit()

l = 0
for i in range(n):
    j = (i + 1) % n
    m = a[j]-a[i]
    if (m - k) % n != 0:
        print("NO")
        exit()
    l -= (m - k) // n
if k == l:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
#b fast
n = int(input())
a = [int(i) for i in input().split()]
sum_a = sum(a)

#s = int((n*(n-1))/2)
s = n*(n+1)//2
if sum_a%s!=0:
    print("NO")
else:
    times = sum_a//s
    stock = times
    ind = 0
    for _ in range(n):
        next_ind= (ind+1)%n
        now = a[ind]
        tsugi = a[next_ind]
        now += times
        
        q,r = divmod(now-tsugi, n)
        stock -= q
        if r!=0 or stock<0:
            print("NO")
            exit()
        ind = next_ind
    if stock==0:
        print("YES")

Submission status: Wrong Answer

Solution code:
try:
    x=int(input())
    n=list(map(int,input().split()))
    if max(n) >= x:
        print("YES")
    else:
        print("NO")
except:
    pass

Submission status: Wrong Answer

Solution code:
x=int(input())
n=list(map(int,input().split()))
if max(n) >= x:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())
M = (N+1)*N//2
S = sum(A)
if S%M!=0:
  print('NO')
  exit()
cnt = S//M
for i in range(N):
  df = A[(i+1)%N]-A[i]
  if (cnt-df)%N!=0 or cnt<df:
    print('NO')
    break
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())
M = (N+1)*N//2
S = sum(A)
if S%M!=0:
  print('NO')
  exit()
cnt = S//M
x = 0
for i in range(N):
  df = A[(i+1)%N]-A[i]
  if (cnt-df)%N!=0 or cnt<df:
    print('N0')
    break
  x += (cnt-df)//N
else:
  if x==cnt:
    print('YES')
  else:
    print('NO')

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())
M = (N+1)*N//2
S = sum(A)
if S%M!=0:
  print('No')
  exit()
cnt = S//M
x = 0
for i in range(N):
  df = A[(i+1)%N]-A[i]
  if (cnt-df)%N!=0 or cnt<df:
    print('No')
    break
  x += (cnt-df)//N
else:
  if x==cnt:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
num = 2 * sum(a) // n // (n + 1)
dif = [0 for _ in range(n)]
for i in range(n - 1):
    dif[i] = a[i] - a[i + 1] + num
dif[n - 1] = a[n - 1] - a[0] + num
tt = 0
for i in range(n):
    if dif[i] % n != 0:
        print('NO')
        exit()
    else:
        tt += dif[i] // n
if tt == num:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
suma = sum(a)
if len(set(a)) != n or suma % n != 0:
    print('NO')
    exit()
num = 2 * suma // n // (n + 1)
dif = [0 for _ in range(n)]
for i in range(n - 1):
    dif[i] = - a[i + 1] + a[i] + num
dif[n - 1] = - a[0] + a[n - 1] + num
tt = 0
for i in range(n):
    if dif[i] % n != 0:
        print('NO')
        exit()
    else:
        tt += dif[i] // n
if tt == num:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
suma = sum(a)
if len(set(a)) != n or suma % n != 0:
    print('NO')
    exit()
num = 2 * suma // n // (n + 1)
dif = [0 for _ in range(n)]
for i in range(n - 1):
    dif[i] = - a[i + 1] + a[i] + num
dif[n - 1] = - a[0] + a[n - 1] + num
tt = 0
for i in range(n):
    if dif[i] % n != 0:
        print('NO')
        exit()
    else:
        tt += dif[i] // n
if tt == num:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
suma = sum(a)
if len(set(a)) != n or suma % n != 0:
    print('NO')
    exit()
num = 2 * suma // n // (n + 1)
dif = [0 for _ in range(n)]
for i in range(n - 1):
    dif[i] = a[i + 1] - a[i] - num
dif[n - 1] = a[0] - a[n - 1] - num
if sum(dif) != - n * num:
    print('NO')
    exit()
tt = 0
for i in range(n):
    if dif[i] % n != 0:
        print('NO')
        exit()
    else:
        tt -= dif[i] // n
if tt == num:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
suma = sum(a)
if len(set(a)) != n or suma % n != 0:
    print('NO')
    exit()
num = 2 * suma // n // (n + 1)
dif = [0 for _ in range(n)]
for i in range(n - 1):
    dif[i] = a[i + 1] - a[i] - num
dif[n - 1] = a[0] - a[n - 1] - num
if sum(dif) != - n * num:
    print('NO')
    exit()
for i in range(n):
    if dif[i] % n != 0:
        print('NO')
        exit()
print('YES')

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
suma = sum(a)
if len(set(a)) != n or suma % n != 0:
    print('NO')
    exit()
num = 2 * suma // n // (n + 1)
dif = [0 for _ in range(n)]
for i in range(n - 1):
    dif[i] = a[i + 1] - a[i] - num
dif[n - 1] = a[0] - a[n - 1] - num
for i in range(n):
    if dif[i] % n != 0:
        print('NO')
print('YES')

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
if len(set(a)) != n or sum(a) % n != 0:
    print('NO')
    exit()
a.sort()
dif = [0 for _ in range(n - 1)]
for i in range(n - 1):
    dif[i] = a[i + 1] - a[i]
if dif == list(reversed(dif)):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
if len(set(a)) == n:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
def solve(n, aaa):
    added_onetime = n * (n + 1) // 2
    total = sum(aaa)
    d, m = divmod(total, added_onetime)
    if m != 0:
        return False
    cnt = 0
    for a1, a2 in zip(aaa, aaa[1:] + aaa[:1]):
        k = d - (a2 - a1)
        kd, km = divmod(k, n)
        if km != 0:
            return False
        cnt += kd
    assert cnt == d
    return True


n = int(input())
aaa = list(map(int, input().split()))
print('YES' if solve(n, aaa) else 'NO')

Submission status: Wrong Answer

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

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

sum_N = N * (N + 1) // 2
sum_A = sum(A)

if sum_A % sum_N != 0:
    print("NO")
    exit()
else:
    k = sum_A // sum_N

B = []
for i in range(N):
    if i + 1 != N:
        B.append(A[i + 1] - A[i] - k)
    else:
        B.append(A[0] - A[i] - k)

cnt = 0
for b in B:
    if b % N != 0:
        print("NO")
        exit()
    else:
        k += b // N 

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

Submission status: Wrong Answer

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

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

sum_N = N * (N + 1) // 2
sum_A = sum(A)
if sum_A % sum_N != 0:
    print("NO")
    exit()
    
mal = sum_A // sum_N
B = [(i + 1) * mal for i in range(N)]

tmp = [A[i] - B[i] for i in range(N)]
for i in range(N - 1):
    if (tmp[i] - tmp[i]) % N != 0:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
k = sum(a) // (n*(n+1)//2)
if n*(n+1)*k // 2 != sum(a):
  print('NO'); exit(0)
b = [a[i] - a[i-1] - k for i in range(n)]
for x in b:
  if x%n: print('NO'); break
else:
  print('YES')

Submission status: Wrong Answer

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

import sys

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()

total = sum(A)
each = N*(N+1) // 2
if total % each != 0:
    NO()
    exit()
# 操作回数
K = total // each

# A各値の差分で数列Bを作る
B = [0] * N
for i in range(N):
    j = (i+1) % N
    B[i] = A[j] - A[i]
# ここからK引けば、1度の操作につきBのいずれかの要素を+N、とできる
B = [b-K for b in B]

if all(b % N == 0 for b in B) and -sum(B) // N == K:
    YES()
else:
    NO()

Submission status: Wrong Answer

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

import sys

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()

total = sum(A)
each = N*(N+1) // 2
if total % each != 0:
    NO()
    exit()
# 操作回数
K = total // each

# A各値の差分で数列Bを作る
B = [0] * N
for i in range(N):
    j = (i+1) % N
    B[i] = A[j] - A[i]
# ここからK引けば、1度の操作につきBのいずれかの要素を+5、とできる
B = [b-K for b in B]

if all(b % N == 0 for b in B):
    YES()
else:
    NO()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int,input().split()))
B = []
for i in range(n):
    B.append(A[i] - A[i-1])

m = max(B)
no = 0

if m < 0:
    no = 1
elif m == 0:
    if A[0] != n*(n+1)//2:
        no = 1
else:
    c = 0
    for i in range(n):
        if (m - B[i]) % n > 0:
            no = 1
        else:
            c += (m - B[i]) // n

    if c != m:
        no = 1
    if sum(A) != m * n*(n+1)//2:
        no = 1

if no==1:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int,input().split()))
B = []
for i in range(n):
    B.append(A[i] - A[i-1])

m = max(B)
no = 0

if m < 0:
    no = 1

c = 0
for i in range(n):
    if (m - B[i]) % n > 0:
        no = 1
    else:
        c += (m - B[i]) // n

if c != m:
    no = 1
if sum(A) != m * n*(n+1)//2:
    no = 1

if no==1:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    s=sum(a)
    if s%(n*(n+1)//2) != 0:
        return "NO"
    k=s//(n*(n+1)//2)
    for i in range(n-1):
        if (a[i]-a[i+1]+k)%n!=0:
            return "NO"
    if (a[-1]-a[0]+k)%n!=0:
        return "NO"
    return "YES"

print(main())

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    s=sum(a)
    if s%(n*(n+1)//2) != 0:
        return "NO"
    k=s//(n*(n+1)//2)
    for i in range(n-1):
        if (a[i]-a[i+1]+k)%n!=0:
            return "NO"
    return "YES"

print(main())

Submission status: Wrong Answer

Solution code:
"""
基本の差はable

 1  2 3  4 5
 4  5 1  2 3
+2  3 4  5 1

 7 10 8 11 9
sa3 -2 3 -2 -2

一度も選ばれてない=3
選ばれてる = -2
一回で -5・・・？
一回選ばれると本来あった +1が消えて -4される →よって-5
"""

import sys

N = int(input())

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

M = N*(N+1)//2

if sum(A) % M != 0:
    print ("NO")
    sys.exit()

able = sum(A) // M

#print (M,able)

A.append(A[0])
now = 0

for i in range(N):

    if A[i+1] - A[i] == able:
        continue

    else:
        #print (A[i+1],A[i],able,1-N)
        if ((A[i+1]-A[i])-able) % (0-N) != 0:
            print ("NO")
            sys.exit()

        else:
            now += ((A[i+1]-A[i])-able) // (0-N)


if now == able:
    print ("YES")
else:
    print ("NO")

Submission status: Wrong Answer

Solution code:
"""
基本の差はable

 1  2 3  4 5
 4  5 1  2 3
+2  3 4  5 1

 7 10 8 11 9
sa3 -2 3 -2 -2

一度も選ばれてない=3
選ばれてる = -2
一回で -5・・・？
一回選ばれると本来あった +1が消えて -4される →よって-5
"""

import sys

N = int(input())

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

M = N*(N+1)//2

if sum(A) % M != 0:
    print ("NO")
    sys.exit()

able = sum(A) // M

#print (M,able)

A.append(A[0])
now = 0

for i in range(N):

    if A[i+1] - A[i] == able:
        continue

    else:
        #print (A[i+1],A[i],able,1-N)
        if ((A[i+1]-A[i])-able) % (0-N) != 0:
            print ("NO")
            sys.exit()

        else:
            now += ((A[i+1]-A[i])-able) // (0-N)


if now <= able:
    print ("YES")
else:
    print ("NO")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(a) for a in input().split()]
S = sum(A)
if S % (N * (N+1) // 2):
    print("NO")
    exit()
C = S * 2 // (N * (N+1))
X = [A[i] - i * C for i in range(N)]
K = 0
L = 0
for i in range(1, N):
    if (X[i-1] - X[i]) % N:
        print("NO")
        exit()
    t = (X[i-1] - X[i]) // N
    K += t
    L += t * (N + 1 - i)

if K > C:
    print("NO")
    exit()
if A[0] == C - K + L:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
def examA():
    N = I()
    A = LI()
    ans = "YES"
    cur = 0
    for a in A:
        if a%2==1:
            cur +=1
    if cur%2==1:
        ans = "NO"
    print(ans)
    return

def examB():
    N = I()
    A = LI()
    ans = "YES"
    sumA = sum(A)
    oneA = (1+N)*N//2
    if sumA%oneA!=0:
        ans = "NO"
    ope = sumA//oneA
    #各Aについて何回始点としたか二分探索
    cur = 0
    for i in range(N):
        now = ope - (A[i]-A[i-1])
        if now%N!=0:
#            print(now,i)
            ans = "NO"
            break
        cur += now//N
    if cur!=ope:
        ans = "NO"
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examB()

Submission status: Wrong Answer

Solution code:
def examA():
    N = I()
    A = LI()
    ans = "YES"
    cur = 0
    for a in A:
        if a%2==1:
            cur +=1
    if cur%2==1:
        ans = "NO"
    print(ans)
    return

def examB():
    N = I()
    A = LI()
    ans = "YES"
    sumA = sum(A)
    oneA = (1+N)*N//2
    if sumA%oneA>0:
        ans = "NO"
    ope = sumA//oneA
    #各Aについて何回始点としたか二分探索
    cur = 0
    for i in range(N):
        now = ope - (A[i]-A[i-1])
        if now%N>0:
#            print(now,i)
            ans = "NO"
            break
        cur += now//N
    if cur==ope:
        ans = "NO"
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examB()

Submission status: Wrong Answer

Solution code:
def examA():
    N = I()
    A = LI()
    ans = "YES"
    cur = 0
    for a in A:
        if a%2==1:
            cur +=1
    if cur%2==1:
        ans = "NO"
    print(ans)
    return

def examB():
    N = I()
    A = LI()
    ans = "YES"
    sumA = sum(A)
    oneA = (1+N)*N//2
    if sumA%oneA!=0:
        ans = "NO"
    ope = sumA//oneA
    #各Aについて何回始点としたか二分探索
    cur = copy.deepcopy(ope)
    for i in range(N):
        now = ope - (A[i]-A[i-1])
        if now%N>0:
#            print(now,i)
            ans = "NO"
            break
        cur -= now//N
    if cur!=0:
        ans = "NO"
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examB()

Submission status: Wrong Answer

Solution code:
def examA():
    N = I()
    A = LI()
    ans = "YES"
    cur = 0
    for a in A:
        if a%2==1:
            cur +=1
    if cur%2==1:
        ans = "NO"
    print(ans)
    return

def examB():
    N = I()
    A = LI()
    ans = "YES"
    sumA = sum(A)
    oneA = (1+N)*N//2
    if sumA%oneA!=0:
        ans = "NO"
    ope = sumA//oneA
    #各Aについて何回始点としたか二分探索
    cur = ope
    for i in range(N):
        now = ope - (A[i]-A[i-1])
        if now%N>0:
#            print(now,i)
            ans = "NO"
            break
        cur -= now//N
    if cur!=0:
        ans = "NO"
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examB()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    N=n*(n+1)//2

    if(sum(A)%N):
        print("NO")
        return

    k=sum(A)//N
    c=0
    for i in range(n):
        if((k-(A[(i+1)%n]-A[i]))%n):
            print("NO")
            return
        c+=(k-(A[(i+1)%n]-A[i]))//n

    print("YES" if(k==c) else "NO")
resolve()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    nn = (n*(n+1))//2
    sum_ = sum(a)
    a += [a[0]]
    cnt = sum_//nn
    if sum_ % nn != 0:
        print("NO")
        return 0
    ans = 0
    for i in range(n):
        p = a[i]-a[i+1]+cnt
        if p % n != 0:
            print("NO")
            return 0
        ans += p//n
    if ans == cnt:
        print("YES")
    else:
        print("NO")


main()

Submission status: Wrong Answer

Solution code:
print("YES")

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    nn = (n*(n+1))//2
    sum_ = sum(a)
    a += [a[0]]
    cnt = sum_//nn
    if sum_ % nn != 0:
        print("NO")
        return 0
    ans = 0
    for i in range(n):
        p = a[i]-a[i+1]+cnt
        if p % n != 0:
            print("NO")
            break
        ans += p//n
    if ans == cnt:
        print("YES")
    else:
        print("NO")


main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    nn = (n*(n+1))//2
    sum_ = sum(a)
    a += [a[0]]
    cnt = sum_//nn
    if sum_ % nn != 0:
        print("NO")
        return 0
    ans = 0
    for i in range(n):
        p = a[i]-a[i+1]+cnt
        if p % n != 0:
            print("NO")
            break
        ans += p//n
    if ans <= cnt:
        print("YES")
    else:
        print("NO")


main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    nn = (n*(n+1))//2
    sum_ = sum(a)
    a += [a[0]]
    cnt = sum_//nn
    if sum_ % nn != 0:
        print("NO")
        return 0
    ans = 0
    ans2 = 0
    for i in range(n):
        p = a[i]-a[i+1]+cnt
        ans2 += p // n
        if p % n != 0:
            print("NO")
            break
        ans += p//n
    if ans <= cnt:
        print("YES")
    else:
        print("NO")


main()

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
d=[j-i for i,j in zip(a,a[1:]+[a[0]])]
M=max(d)
dd=[M-x for x in d]
if all(x%n==0 for x in dd) and sum(x//n for x in dd)==M:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
N = int(input())
a = list(map(int, input().split()))
d = [0] * N
for i in range(1, N):
  d[i] = a[i] - a[i - 1]
d[0] = a[0] - a[-1]
#print(d)
if sum(a) % (N * (N + 1) // 2):
  print("NO")
  exit(0)
f = 0
m = sum(a) // (N * (N + 1) // 2)
c = 0
for i in range(N):
  c += (m - d[i]) // N
  if c == m:
    f = 1
  else: f = 0
if c == 0:
  r = m
if c > m:
  l = m

if f:
  print("YES")
else: print("NO")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
N = int(input())
a = list(map(int, input().split()))
d = [0] * N
for i in range(1, N):
  d[i] = a[i] - a[i - 1]
d[0] = a[0] - a[-1]
f = 0
m = sum(a) // (N * (N + 1) // 2)
c = 0
for i in range(N):
  c += (m - d[i]) // N
  if c == m:
    f = 1
  else: f = 0
if c == 0:
  r = m
if c > m:
  l = m
if f:
  print("YES")
else: print("NO")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
N = int(input())
a = list(map(int, input().split()))
d = [0] * N
for i in range(1, N):
  d[i] = a[i] - a[i - 1]
d[0] = a[0] - a[-1]
#print(d)

l = min(a) // N
r = max(a)
f = 0
for _ in range(100):
  m = int((l + r) / 2)
  if m == 0: break
  c = 0
  t = [0] * N
  for i in range(N):
    if (m - d[i]) % N: break
    c += (m - d[i]) // N
    t[i] = (m - d[i]) // N
    if c == m:
      f = 1
    else: f = 0
  #print(m,c)
  if f: break
  if c == 0:
    r = m
  if c > m:
    l = m

if f:
  if m * N * (N + 1) // 2 == sum(a):
    print("YES")
  else: print("NO")
else: print("NO")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
N = int(input())
a = list(map(int, input().split()))
d = [0] * N
for i in range(1, N):
  d[i] = a[i] - a[i - 1]
d[0] = a[0] - a[-1]
#print(d)

l = min(a) // N
r = max(a)
f = 0
for _ in range(100):
  m = int((l + r) / 2)
  if m == 0: break
  c = 0
  t = [0] * N
  for i in range(N):
    if (m - d[i]) % N: break
    c += (m - d[i]) // N
    t[i] = (m - d[i]) // N
    if c == m:
      f = 1
    else: f = 0
  #print(m,c)
  if f: break
  if c == 0:
    r = m
  if c > m:
    l = m

if f:
  k = 0
  for i in range(N):
    k += (1 + ((N - 1) - i)) * t[i]
  if k == a[-1]:
    print("YES")
  else: print("NO")
else: print("NO")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
N = int(input())
a = list(map(int, input().split()))
d = [0] * N
for i in range(1, N):
  d[i] = a[i] - a[i - 1]
d[0] = a[0] - a[-1]
l = min(a) // N
r = max(a)
f = 0
for _ in range(100):
  m = int((l + r) / 2)
  if m == 0: break
  t = [m] * N
  c = 0
  for i in range(N):
    if (t[i] - d[i]) % N: break
    c += (t[i] - d[i]) // N
    if c == m:
      f = 1
    else: f = 0
  if f: break
  if c == 0:
    r = m
  if c > m:
    l = m
if f: print("YES")
else: print("NO")