AtCoder Beginner Contest #260.

A - A Unique Lette

Problem Statement

You are given a string of length .
Print a character that occurs only once in .
If there is no such character, print -1 instead.

Constraints

  • S is a string of length 3 consisting of lowercase English letters.
  • Print the answer. If multiple solutions exist, you may print any of them.

 

示例输入 1

pop

示例输出 1

o

 

s=input()
dict={}
f=0
for i in s:dict[i] = 1 if i not in dict else dict[i] + 1
for i in range(len(s)):
    if dict[s[i]]==1:
        ss=s[i]
        f=1
        break
if f:print(ss)
else:print(-1)

 

 

B - Better Students Are Needed!

Problem Statement--(English)

N examinees took an entrance exam.

N个考生参加了入学考试。)
The examinee numbered scored points in math and points in English.i

(考生在数学和英语中得分分别表示为 i

The admissions are determined as follows.

(录取决定如下)

  1. X examinees with the highest math scores are admitted.X个数学成绩最高的考生被录取)
  2. Then, among the examinees who are not admitted yet, Yexaminees with the highest English scores are admitted.(然后,在尚未被录取的考生中,英语分数最高的考生录取Y个)
  3. Then, among the examinees who are not admitted yet, Zexaminees with the highest total scores in math and English are admitted.(然后,在尚未被录取的考生中,数学和英语总分最高的考生录取Z个)
  4. Those examinees who are not admitted yet are rejected.(那些尚未被录取的考生将被拒绝)

Here, in each of the steps 1. to 3., ties are broken by examinees' numbers: an examinee with the smaller examinee's number is prioritized. See also Sample Input and Output.

Print the examinees' numbers of the admitted examinees determined by the steps above in ascending order, separated by newlines.

(在这里,在每个步骤中 1.到3.,考生人数打破了联系:考生序号较前的考生被优先考虑。另请参见示例输入和输出。按升序打印由上述步骤确定的考生人数,以换行符分隔。)

Constraints

  • All values in input are integers.
  • 1 \le N \le 1000
  • 0 \le X,Y,Z \le N
  • 1 \le X+Y+Z \le N
  • 0 \le A_i,B_i \le 100

示例输入 1

6 1 0 2
80 60 80 60 70 70
40 20 50 90 90 80

示例输出 1

1
4
5

 

示例输入 2

5 2 1 2
0 100 0 100 0
0 0 100 100 0

示例输出 2

1
2
3
4
5

 

n,x,y,z=map(int,input().split())
m=x+y+z
a=[0]+list(map(int,input().split()))
b=[0]+list(map(int,input().split()))
c=[0]*(n+1)
d=[[-1,-1,-1,-1]]
for i in range(1,n+1):
    c[i]=a[i]+b[i]
for i in range(1,n+1):
    d.append([i,a[i],b[i],c[i]])
mk=[]
d.sort(reverse=True,key=lambda x:(x[1],-x[0]))
for i in range(x):
    if x==0:break
    mk.append(d[0][0])
    d.remove(d[0])
d.sort(reverse=True, key=lambda x: (x[2], -x[0]))
for i in range(y):
    if y==0:break
    mk.append(d[0][0])
    d.remove(d[0])
d.sort(reverse=True, key=lambda x: (x[3], -x[0]))
for i in range(z):
    if z==0:break
    mk.append(d[0][0])
    d.remove(d[0])
mk.sort()
for i in mk:
    print(i)

 

posted @ 2022-07-21 12:15  难忘你  阅读(44)  评论(0)    收藏  举报