0 点赞 评论 收藏
分享
2020-04-12 18:11
哈尔滨工业大学 Java Yasu0:第三题贪心
```
class Man implements Comparable<Man> {
int a;
int b;
int id;
int c;
public Man(int a, int b, int id, int c) {
this.a = a;
this.b = b;
this.id = id;
this.c = c;
}
@Override
public int compareTo(Man o) {
if (o.c == this.c)
return o.a - this.a;
return o.c - this.c;
}
}
/**
* 根据顾客属性计算出顾客排队顺序
*
* @param a int整型一维数组 顾客a属性
* @param b int整型一维数组 顾客b属性
* @return int整型一维数组
*/
public int[] WaitInLine(int[] a, int[] b) {
int len = a.length;
List<Man> l = new ArrayList<>();
for (int i = 0; i < len; i++)
l.add(new Man(a[i], b[i], i + 1, a[i] - b[i]));
Collections.sort(l);
int[] res = new int[len];
for (int i = 0; i < len; i++)
res[i] = l.get(i).id;
return res;
}
```

0 点赞 评论 收藏
分享
goldfish_h...:str_1 = input()
str_2 = input()
i = j = k = 0
length = len(str_1)
for i in range(length):
if str_1[i] == str_2[j]:
j += 1
else:
k += 1
print(k)

0 点赞 评论 收藏
分享
创作者周榜
更多
关注他的用户也关注了: