山东csp-j2022 试题答案及视频讲解
T319771 植树节(planting)山东CSP-J2022 入门组1
题目链接:https://www.luogu.com.cn/problem/T319771
题目讲解:
#include<iostream> #include<cmath> using namespace std; const int N=1000010; int n; int a,b,mmin=N,mmax=0; int num[N]; int ans=0; void insert(int x,int y) { num[x]++; num[y+1]--; } int main() { scanf("%d",&n); for(int i=1; i<=n; i++) { scanf("%d %d",&a,&b); insert(a,b);//差分,插入 mmin=min(a,mmin); mmax=max(b,mmax); } //计算 int t=0; for(int i=mmin; i<=mmax; i++) { t+=num[i]; ans=max(t,ans); } printf("%d",ans); return 0; }
T319773 宴会(banquet) 山东CSP-J2022 入门组2
题目链接:https://www.luogu.com.cn/problem/T319773
题目讲解:
标签:int,csp,num,讲解,试题答案,j2022 From: https://www.cnblogs.com/mantou20210331/p/17189798.html