Submission #73070122
Source Code Expand
import sys
from collections import Counter
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lii = lambda: list(mii())
MOD = 10**9+7
inf = 1<<64
def solve():
n = ii()
a = lii()
a.sort()
cnt = Counter(a)
ans = set()
s = sum(a)
mx = max(a)
for m in range((n + 1) // 2, n + 1):
if s%m!=0:
continue
k = s//m
if k<mx:
continue
x = 2*m-n
if x < 0:
continue
if cnt.get(k, 0) < x:
continue
l, r = 0,n - 1
cn = 0
ok = True
while l < r:
while cn<x and a[l] == k:
l += 1
cn += 1
if l >= r:
break
if l >= r:
break
while cn < x and a[r] == k:
r -= 1
cn += 1
if l >= r:
break
if l >= r:
break
if a[l] + a[r] != k:
ok = False
break
l += 1
r -= 1
if ok:
ans.add(k)
ans = sorted(ans)
print(*ans)
t = 1
# t = ii()
for _ in range(t):
solve()
Submission Info
| Submission Time | |
|---|---|
| Task | C - AtCoder Riko |
| User | xiaoe |
| Language | Python (PyPy 3.11-v7.3.20) |
| Score | 350 |
| Code Size | 1317 Byte |
| Status | AC |
| Exec Time | 177 ms |
| Memory | 213520 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 350 / 350 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 0_sample_1.txt, 0_sample_2.txt, 0_sample_3.txt |
| All | 0_sample_1.txt, 0_sample_2.txt, 0_sample_3.txt, 1_1.txt, 1_2.txt, 1_3.txt, 1_4.txt, 1_5.txt, 2_1.txt, 2_2.txt, 2_3.txt, 2_4.txt, 3_1.txt, 3_2.txt, 3_3.txt, 3_4.txt, 3_5.txt, 3_6.txt, 4_1.txt, 4_2.txt, 4_3.txt, 4_4.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 0_sample_1.txt | AC | 59 ms | 93664 KiB |
| 0_sample_2.txt | AC | 59 ms | 93812 KiB |
| 0_sample_3.txt | AC | 58 ms | 93416 KiB |
| 1_1.txt | AC | 156 ms | 195444 KiB |
| 1_2.txt | AC | 159 ms | 194428 KiB |
| 1_3.txt | AC | 158 ms | 194876 KiB |
| 1_4.txt | AC | 159 ms | 194972 KiB |
| 1_5.txt | AC | 158 ms | 194228 KiB |
| 2_1.txt | AC | 176 ms | 212904 KiB |
| 2_2.txt | AC | 177 ms | 213304 KiB |
| 2_3.txt | AC | 177 ms | 213520 KiB |
| 2_4.txt | AC | 176 ms | 213004 KiB |
| 3_1.txt | AC | 162 ms | 187700 KiB |
| 3_2.txt | AC | 151 ms | 171804 KiB |
| 3_3.txt | AC | 146 ms | 164828 KiB |
| 3_4.txt | AC | 129 ms | 163344 KiB |
| 3_5.txt | AC | 64 ms | 93692 KiB |
| 3_6.txt | AC | 140 ms | 158264 KiB |
| 4_1.txt | AC | 104 ms | 149116 KiB |
| 4_2.txt | AC | 111 ms | 162632 KiB |
| 4_3.txt | AC | 62 ms | 93620 KiB |
| 4_4.txt | AC | 61 ms | 93720 KiB |