public class q4_21 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); HashMap<Integer,Integer> hashMap = new HashMap(); for (int i = 0; i < 24; i++) { hashMap.put(i,0); } for (int i = 0; i < N; i++) { int begin = sc.nextInt(); int end = sc.nextInt(); int customer = sc.nextInt(); int flag = 0; for (int j = begin; j < end; j++) { if(hashMap.get(j)+customer>M){ flag = 1 ; break; } } if(flag == 0) { for (int j = begin; j < end; j++) { hashMap.put(j, hashMap.get(j) + customer); } } flag = 0; } for (int i = 0; i < 24; i++) { System.out.print(hashMap.get(i)+" "); } } }
点赞 2

相关推荐

牛客网
牛客企业服务