值周
值周
https://ac.nowcoder.com/acm/problem/24636
区间上修改,操作简单,就考虑下差分;
#include<bits/stdc++.h> #include<cstdio> using namespace std; #define int long long const int maxn=1e8+6; int ans,a[maxn]; signed main() { int l,m; scanf("%lld %lld",&l,&m); for(int i=1;i<=m;i++) { int x,y; scanf("%lld %lld",&x,&y); a[x]++,a[y+1]--; } int h=0; for(int i=0;i<=l;i++) { h+=a[i]; if(h==0) ans++; } cout<<ans; }