-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ05053_SapXepDonHang.java
47 lines (47 loc) · 1.21 KB
/
J05053_SapXepDonHang.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.io.*;
import java.util.*;
import java.math.*;
class Delivery{
private String name,id,stt;
private long dg,sl,gg,tt;
public Delivery(String tenHang,String maDon,long dg,long sl)
{
this.name = tenHang;
this.id = maDon;
this.stt = maDon.substring(1,4);
this.sl = sl;
this.dg = dg;
this.gg = dg*50*sl/100;
if(maDon.charAt(4)=='2') this.gg = dg*30*sl/100;
this.tt = this.sl*this.dg - this.gg;
}
@Override
public String toString()
{
return name+" "+id+" "+stt+" "+gg+" "+tt;
}
public int getStt()
{
return Integer.valueOf(this.stt);
}
}
public class J05053_SapXepDonHang {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
ArrayList<Delivery> a = new ArrayList<>();
for(int i = 1;i<=n;i++)
{
sc.nextLine();
a.add(new Delivery(sc.nextLine(),sc.nextLine(),sc.nextLong(),sc.nextLong()));
}
Collections.sort(a,new Comparator<Delivery>(){
@Override
public int compare(Delivery t, Delivery t1) {
return t.getStt()>t1.getStt()?1:-1;
}
});
for(Delivery dh:a)
System.out.println(dh);
}
}