#20618: Python 3行


TCFSH69 (TCFSH)

學校 : 國立臺中第一高級中學
編號 : 81602
來源 : [140.116.191.189]
最後登入時間 :
2022-09-01 23:15:51

import sys
for line in sys.stdin:
    print(' '.join(str(i) for i in sorted(list(map(int,sys.stdin.readline().replace('\n','').split())),key = lambda x:(x % 10,-x))))

 

求大神協助 讓他可以跑得更快一點(原本26ms)

#20750: Re:Python 3行


devil1004@livemail.tw (yanru)

學校 : 國立高雄應用科技大學
編號 : 115422
來源 : [192.192.101.7]
最後登入時間 :
2025-09-02 23:38:38

import sys
for line in sys.stdin:
    print(' '.join(str(i) for i in sorted(list(map(int,sys.stdin.readline().replace('\n','').split())),key = lambda x:(x % 10,-x))))

 

求大神協助 讓他可以跑得更快一點(原本26ms)

24ms

while True:
    try:
        n = int(input())
        n = [int(i) for i in input().strip().split(' ')]
        n.sort(reverse=True)
        n.sort(keylambda x: x%10)
        print(' '.join([str(i) for i in n]))

    except:
        break