首页 > 编程知识 正文

杭电oj平台,杭电oj题库

时间:2023-05-04 21:23:46 阅读:206341 作者:1578

杭电2093题,激昂的太阳/p>

虽然不难但很麻烦。

import java.util.ArrayList;

import java.util.Collections;

import java.util.List;

import java.util.Scanner;

/**

class node implements Comparable{

String name;

int num;

int time;

public node(String name, int num, int time) {

this.name = name;

this.num = num;

this.time = time;

}

@Override

public int compareTo(node o) {

if(this.num

return 1;

}else if(this.num>o.num){

}else {

if(this.time>o.time){

return 1;

}else if(this.time

}else {

return this.name.compareTo(o.name)>0?1:-1;

}

}

}

}

public class Main {

public static void main(Stringnrdyl args) {

Scanner sc = new Scanner(System.in);

List list = new ArrayList<>();//记录每个学生的姓名、AC数和time

int n = sc.nextInt();

int m = sc.nextInt();

while (sc.hasNext()){

String name = sc.next();

int time = 0,num = 0;

for (int k = 0; k < n; k++) {

String s = sc.next();

if(s.charAt(0)=='-'|| s.equals("0")){

continue;

}else if(s.contains("(")){

num ++; //AC数加yxdxs/p>

//计算用时

int tmp = 0;

int i = 0;

for (i = 0; s.charAt(i)!='(' ; i++) {

tmp = tmp*10+(s.charAt(i)-'0');

}

time += tmp;

//计算罚时

tmp = 0;

for (int j = i+1; s.charAt(j)!=')'; j++) {

tmp = tmp*10+(s.charAt(j)-'0');

}

time+=tmp*m;

}else {

int tmp = 0;

for (int i = 0; i

tmp = tmp*10+(s.charAt(i)-'0');

}

num++;

time+=tmp;

}

}

//建node

node nodex = new node(name,num,time);

list.add(nodex);

}

Collections.sort(list); //排序

//按要求输出

for (node nodex:list) {

}

sc.close();

}

}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。