某公司举办了为期D天的活动,共有N人参加。参与者i计划从第Li天到第Ri天出席。请编写一个程序输出每天的出席者人数。
输入方式:
输出方式:
输出D行。第d行输出第d天的出席者人数。
约束条件:
输入用例:
8
5
2 3
3 6
5 7
3 7
1 5
输出用例:
1 2 4 3 4 3 2 0
import java.util.Scanner; class Main{ public static void main(String[]args) { Scanner sc=new Scanner(System.in); int N,Q; N=sc.nextInt(); Q=sc.nextInt(); int [] A=new int[100009]; int [] B=new int[100009]; int [] L=new int[100009]; int [] R=new int[100009]; for (int i = 1; i <= Q; i++) { L[i]=sc.nextInt(); R[i]=sc.nextInt(); } for (int i = 1; i <= N; i++) { A[i]=i; } for (int i = 1; i <= Q; i++) { for (int j = L[i]; j <=R[i] ; j++) { B[j]=B[j]+1; } } for (int i = 1; i <= N; i++) { System.out.println(B[i]); } } }