ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 I. Illegal or Not?

I. Illegal or Not?
time limit per test
1 second
memory limit per test
512 megabytes
input
standard input
output
standard output

The Schengen Agreement was signed by a number of countries to uniform many visa-related questions and to allow tourists from outside of the Schengen area to enter and freely travel within Schengen member states using only one visa. A multiple-entry visa owner can perform many travels to any Schengen member state using a single visa, but migration laws limit the number of days he is allowed to stay there. For any consecutive 180 days a visa owner is only allowed to be inside the Schengen area for no more than 90 days in total.

A tourist has got his 5-year Schengen multiple-entry visa on October 18th 2010, therefore he could travel to and from the Schengen area at any of 5·365 + 1 (2012 was a leap year)  = 1826 days.

Yesterday (October 17th, 2015) was the last day his visa was valid, and the tourist wants to know whether he has broken the migration laws and may face problems with obtaining a new Schengen visa. You are given the information about all trips to the Schengen member states he did using this visa and are to verify the rule about consecutive days for multiple-entry visa holders. According to the Schengen visa rules the day of arrival and the day of departure are considered to be days spent inside the Schengen area.

Input

The first line of the input contains only number of trips n (1 ≤ n ≤ 1826).

The i-th of the following n lines describes the i-th trip with two integers ai and di — the day of arrival to Schengen area and the day of departure respectively (1 ≤ ai ≤ di ≤ 1826). Days are numbered starting from the day the visa was issued.

It is guaranteed that these trips do not overlap, that is, each of 1826 days is a part of no more than one trip. Trips are given in arbitrary order.

Output

Output "Yes" (without quotes) if the tourist has followed the rules and may not worry about a new visa. Print "No" (without quotes) if he needs to start to look for an explanation to give to migration officer.

Sample test(s)
input
1
2 91
output
Yes
input
1
1 91
output
No
input
2
3 91
180 200
output
No
input
2
181 270
1 90
output
Yes
Note

In the second sample the tourist was in Schengen area for 91 days in the 180-day window which starts on day 1.

In the third sample the tourist was in Schengen area for 91 days in the 180-day window which started on day 2 (89 days from day 3 to day 91 and 2 days from day 180 to day 181).

 

题意:给出N个区间,全部变为1,否则为0,问从1到1826范围内,是否有连续的一段(长度固定为180),含有1的部分的长度超过90(同一块不重复Count)

分析:暴力

 

 1 /**
 2 Create By yzx - stupidboy
 3 */
 4 #include <cstdio>
 5 #include <cstring>
 6 #include <cstdlib>
 7 #include <cmath>
 8 #include <deque>
 9 #include <vector>
10 #include <queue>
11 #include <iostream>
12 #include <algorithm>
13 #include <map>
14 #include <set>
15 #include <ctime>
16 #include <iomanip>
17 using namespace std;
18 typedef long long LL;
19 typedef double DB;
20 #define MIT (2147483647)
21 #define INF (1000000001)
22 #define MLL (1000000000000000001LL)
23 #define sz(x) ((int) (x).size())
24 #define clr(x, y) memset(x, y, sizeof(x))
25 #define puf push_front
26 #define pub push_back
27 #define pof pop_front
28 #define pob pop_back
29 #define ft first
30 #define sd second
31 #define mk make_pair
32 
33 inline int Getint()
34 {
35     int Ret = 0;
36     char Ch = ' ';
37     bool Flag = 0;
38     while(!(Ch >= '0' && Ch <= '9'))
39     {
40         if(Ch == '-') Flag ^= 1;
41         Ch = getchar();
42     }
43     while(Ch >= '0' && Ch <= '9')
44     {
45         Ret = Ret * 10 + Ch - '0';
46         Ch = getchar();
47     }
48     return Flag ? -Ret : Ret;
49 }
50 
51 const int N = 2010;
52 int n;
53 bool cnt[N];
54 
55 inline void Input()
56 {
57     scanf("%d", &n);
58     for(int i = 0; i < n; i++)
59     {
60         int l, r;
61         scanf("%d%d", &l, &r);
62         for(int j = l; j <= r; j++)
63             cnt[j] = 1;
64     }
65 }
66 
67 inline void Solve()
68 {
69     for(int i = 0; i <= 1810; i++)
70         for(int j = i, count = 0; j < i + 180; j++)
71         {
72             count += cnt[j];
73             if(count > 90)
74             {
75                 printf("No\n");
76                 return;
77             }
78         }
79     printf("Yes\n");
80 }
81 
82 int main()
83 {
84     Input();
85     Solve();
86     return 0;
87 }
View Code

 

转载于:https://www.cnblogs.com/StupidBoy/p/5075081.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值