/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Runtime Error Traceback (most recent call last): File "foo.py", line 24, in <module> File "foo.py", line 22, in solve TypeError: sequence item 0: expected str instance, int found 15ms 3.023 MiB
#2 Runtime Error Traceback (most recent call last): File "foo.py", line 24, in <module> File "foo.py", line 22, in solve TypeError: sequence item 0: expected str instance, int found 15ms 2.973 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
        # نوبت‌ها را یکی در میان به Roy و Hridoy اختصاص می‌دهیم
        for i in range(N):
            if i % 2 == 0:  # نوبت Roy (جمع می‌کند)
                S += A[i]
            else:           # نوبت Hridoy (کم می‌کند)
                S -= A[i]
        
        results.append(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 15:59:33
Judged At
2025-07-14 15:59:33
Judged By
Score
0
Total Time
15ms
Peak Memory
3.023 MiB