QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#893823#9549. The Magicianhqm01WA 11ms8832kbPython32.1kb2025-02-10 23:09:272025-02-10 23:09:28

Judging History

This is the latest submission verdict.

  • [2025-02-10 23:09:28]
  • Judged
  • Verdict: WA
  • Time: 11ms
  • Memory: 8832kb
  • [2025-02-10 23:09:27]
  • Submitted

answer

def max_flushes():
    import sys
    input = sys.stdin.read().split()
    ptr = 0
    T = int(input[ptr])
    ptr += 1
    for _ in range(T):
        n = int(input[ptr])
        ptr += 1
        cards = input[ptr:ptr + n]
        ptr += n
        t = list(map(int, input[ptr:ptr + 6]))
        ptr += 6
        
        max_flushes_val = 0
        
        for s in ['D', 'C', 'H', 'S']:
            count_s = sum(1 for card in cards if card[1] == s)
            other = n - count_s
            wild = 0
            
            # Apply conversion tarot for s
            if s == 'D' and t[0]:
                conv = min(3, other)
                count_s += conv
                other -= conv
            elif s == 'C' and t[1]:
                conv = min(3, other)
                count_s += conv
                other -= conv
            elif s == 'H' and t[2]:
                conv = min(3, other)
                count_s += conv
                other -= conv
            elif s == 'S' and t[3]:
                conv = min(3, other)
                count_s += conv
                other -= conv
            
            # Apply Lovers
            lovers = t[4]
            if lovers:
                conv_other = min(lovers, other)
                wild += conv_other
                other -= conv_other
                lovers -= conv_other
                conv_s = min(lovers, count_s)
                wild += conv_s
                count_s -= conv_s
            
            # Apply Death
            death = t[5]
            if death:
                possible_death = min(death, other)
                sum1 = (count_s + possible_death) + wild
                sum2 = count_s + (wild + possible_death)
                if sum1 >= sum2:
                    count_s += possible_death
                else:
                    wild += possible_death
                other -= possible_death
            
            total = count_s + wild
            flushes = total // 5
            if flushes > max_flushes_val:
                max_flushes_val = flushes
        
        print(max_flushes_val)

max_flushes()

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 11ms
memory: 8832kb

input:

4
5
2H 3H 4H 5H 6D
1 1 1 1 0 0
5
2S 3S 4D 5C 6D
0 0 1 0 1 1
5
2S 3S 4D 5C 6D
0 0 1 0 1 0
13
AS 2S 3S 4S 5H 6H 7H 8H 9H TH JH QH KH
0 0 0 0 0 1

output:

1
1
0
2

result:

ok 4 lines

Test #2:

score: -100
Wrong Answer
time: 9ms
memory: 8832kb

input:

13
10
AD 2D 3D 4D 5D 6D 7D 8D 9D TD
0 0 1 0 0 0
10
AH 2D 3D 4D 5D 6D 7D 8D 9D TD
0 0 1 0 0 0
10
AH 2H 3D 4D 5D 6D 7D 8D 9D TD
0 0 1 0 0 0
10
AH 2H 3H 4D 5D 6D 7D 8D 9D TD
0 0 1 0 0 0
10
AH 2H 3H 4H 5D 6D 7D 8D 9D TD
0 0 1 0 0 0
10
AS 2S 3S 4S 5S 6S 7S 8S 9S TS
0 1 0 0 0 0
10
AC 2S 3S 4S 5S 6S 7S 8S ...

output:

2
1
1
1
1
2
1
1
1
1
0
0
0

result:

wrong answer 3rd lines differ - expected: '2', found: '1'