codeforces469B
发布时间:2020-12-14 04:35:37 所属栏目:大数据 来源:网络整理
导读:Chat Online ? CodeForces - 469B? 问题描述 你和你的朋友经常在网上聊天. 你的朋友作息规律每天只会在p个时间段[ai,bi]在线. 你作息混乱,假设你在t时刻起床,那么你会在q个时间段[t+ci,t+di]在线. 现在,你有可能会在[l,r]的这个时间段中的任意一个时刻起床,
Chat Online?CodeForces - 469B? 问题描述 你和你的朋友经常在网上聊天. 第一行4个整数p,q,l,r.(1<=p,q<=50;0<=l<=r<=1000)
样例输入1
1 1 0 4
样例输出1
3
样例输入2
2 3 0 20
样例输出2
20
#include <bits/stdc++.h> using namespace std; typedef int ll; inline ll read() { ll s=0; bool f=0; char ch=‘ ‘; while(!isdigit(ch)) { f|=(ch==‘-‘); ch=getchar(); } while(isdigit(ch)) { s=(s<<3)+(s<<1)+(ch^48); ch=getchar(); } return (f)?(-s):(s); } #define R(x) x=read() inline void write(ll x) { if(x<0) { putchar(‘-‘); x=-x; } if(x<10) { putchar(x+‘0‘); return; } write(x/10); putchar((x%10)+‘0‘); return; } #define W(x) write(x),putchar(‘ ‘) #define Wl(x) write(x),putchar(‘n‘) const int N=55; int n,m; int a[N],b[N],c[N],d[N]; int main() { int i,j,k,L,R,ans=0; R(n); R(m); R(L); R(R); for(i=1;i<=n;i++) { R(a[i]); R(b[i]); } for(i=1;i<=m;i++) { R(c[i]); R(d[i]); } for(i=L;i<=R;i++) { bool Bo=0; for(j=1;j<=n&&(!Bo);j++) { bool Flag=0; for(k=1;k<=m&&(!Flag);k++) { if(c[k]+i<=b[j]&&d[k]+i>=a[j]) Flag=1; } if(Flag) Bo=1; } ans+=Bo; } Wl(ans); return 0; } /* input 1 1 0 4 2 3 0 1 output 3 input 2 3 0 20 15 17 23 26 1 4 7 11 15 17 output 20 */ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |