A New Billionaire’s 10 Rules for Success

1 – Get and stay out of your comfort zone.

 

 

2 - Never give up.

 

3 - When you’re ready to quit, you’re closer than you think.

 

4 – Always be moving forward.

 

5 - Be quick to decide.

 

6 - Measure everything of significance.

 

7 - Anything that is not managed will deteriorate.

 

8 – Never expect life to be fair.

 

9 – Don’t take yourself too seriously.

 

10 - There’s always a reason to smile.

 

 

 

(Original link : http://blogs.wsj.com/wealth/2011/06/24/a-new-billionaires-10-rules-for-success/)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
import java.util.*;public class Billionaires { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Map<String, List<Billionaire>> billionairesByCity = new HashMap<>(); for (int i = 0; i < n; i++) { String name = sc.next(); String city = sc.next(); long fortune = sc.nextLong(); Billionaire billionaire = new Billionaire(name, city, fortune); if (!billionairesByCity.containsKey(city)) { billionairesByCity.put(city, new ArrayList<>()); } billionairesByCity.get(city).add(billionaire); } int m = sc.nextInt(); int k = sc.nextInt(); for (int i = 0; i < k; i++) { int day = sc.nextInt(); String name = sc.next(); String city = sc.next(); List<Billionaire> billionaires = billionairesByCity.get(city); for (Billionaire billionaire : billionaires) { if (billionaire.name.equals(name)) { billionaire.addTravel(day); break; } } } List<String> cities = new ArrayList<>(billionairesByCity.keySet()); Collections.sort(cities); for (String city : cities) { List<Billionaire> billionaires = billionairesByCity.get(city); Map<Integer, Long> wealthByDay = new HashMap<>(); for (Billionaire billionaire : billionaires) { for (int day : billionaire.travels) { wealthByDay.put(day, wealthByDay.getOrDefault(day, 0L) + billionaire.fortune); } } int maxDays = 0; for (int day : wealthByDay.keySet()) { long wealth = wealthByDay.get(day); for (int i = day + 1; i <= m; i++) { long futureWealth = wealthByDay.getOrDefault(i, 0L); if (futureWealth > wealth) { break; } if (i - day > maxDays) { maxDays = i - day; } } } if (maxDays > 0) { System.out.println(city + " " + maxDays); } } } static class Billionaire { String name; String city; long fortune; List<Integer> travels = new ArrayList<>(); public Billionaire(String name, String city, long fortune) { this.name = name; this.city = city; this.fortune = fortune; } public void addTravel(int day) { travels.add(day); } }}的计算复杂度是多少
05-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值