LoginSignup
0
0

More than 3 years have passed since last update.

ABC128 A,B,C解説(python)

Posted at

A問題

a,p = map(int,input().split())
print((a*3+p)//2)

a×3+pを2で割ったものが答えとなる。

B問題

n = int(input())
x = [[input().split(),i+1]for i in range(n)]
x = sorted(x, key = lambda x:(x[0][0],-int(x[0][1])))
for i in range(n):
    print(x[i][1])

複数の要素についてソートをかける問題。
x = sorted(x, key = lambda x:(x[0][0],-int(x[0][1])))
でkey を複数指定するとx[0][0]、-int(x[0][1])の順にソートを行う。
出力は番号で行うのでxを入力する際に番号も入れ込んだリストを作成する。

C問題



0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0