/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Runtime Error Traceback (most recent call last): File "foo.py", line 29, in <module> File "foo.py", line 22, in solve ValueError: max() iterable argument is empty 14ms 3.039 MiB
#2 Runtime Error Traceback (most recent call last): File "foo.py", line 29, in <module> File "foo.py", line 22, in solve ValueError: max() iterable argument is empty 14ms 3.043 MiB

Code

def solve():
    T = int(input())
    results = []
    
    for _ in range(T):
        N = int(input())
        A = list(map(int, input().split()))
        
        # مرتب‌سازی بر اساس قدر مطلق نزولی
        A.sort(key=lambda x: abs(x), reverse=True)
        
        S = 0
        temp_list=[]
        # نوبت‌ها را یکی در میان به Roy و Hridoy اختصاص می‌دهیم
        for i in range(N):
            if i % 2 == 0:  # نوبت Roy (جمع می‌کند)
                S += A[i]
            else:           # نوبت Hridoy (کم می‌کند)
                S -= A[i]
            if i >1:
              temp_list.append((S,i))
            S=max(temp_list, key=lambda x: x[0])

        
        results.append(str(S))
    
    print('\n'.join(results))

solve()

Information

Submit By
Type
Submission
Problem
P1208 C. Game on Integer
Contest
Educational Round 1
Language
Python 3 (Python 3.12.3)
Submit At
2025-07-14 16:03:51
Judged At
2025-07-14 16:03:51
Judged By
Score
0
Total Time
14ms
Peak Memory
3.043 MiB