/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 12ms 2.777 MiB
#2 Wrong Answer 12ms 2.828 MiB
#3 Wrong Answer 14ms 2.906 MiB
#4 Accepted 14ms 2.906 MiB
#5 Wrong Answer 16ms 2.902 MiB
#6 Accepted 15ms 3.648 MiB
#7 Accepted 12ms 2.848 MiB

Code

for _ in range(int(input())):
    n = int(input())
    arr = list(map(int, input().split()))

    count = 0

    new_arr = []
    for i in arr:
        if i % 3 == 0:
            count += 1
        else:
            new_arr.append(i)
    new_sum = sum(new_arr)

    if new_sum % 3 == 0:
        count += len(new_arr)
    elif new_sum % 3 == 1:
        if 1 in new_arr:
            count += (len(new_arr) - 1)
    elif new_sum % 3 == 2:
        if 2 in new_arr:
            count += (len(new_arr) - 1)
        elif new_arr.count(1) >= 2:
            count += (len(new_arr) - 2)

    print(count)

Information

Submit By
Type
Submission
Problem
P1013 Divisible by 3
Language
Python 3 (Python 3.12.3)
Submit At
2024-01-06 16:24:14
Judged At
2024-01-06 16:24:14
Judged By
Score
50
Total Time
16ms
Peak Memory
3.648 MiB