ural 1070. Local Time

1070. Local Time

Time limit: 1.0 second
Memory limit: 64 MB

Soon the USU team will go to Vancouver to participate in the final of the ACM International Collegiate Programming Contest. They will be to take four different planes (three changes on the way)!

By the way, our team plans to return from Vancouver, so the two-way tickets are bought. The departure time (local time of the airport of departure) and the time of the arrival (local time of the destination airport) are printed on the tickets.

For example, the departure at 15.42 and the arrival at 16.23, and a return flight departs at 08.10 and arrives at 17.51.

Your task is to help to our team to find out how much does the time of the first airport differs from the one of the second. It is known that time in different airports differs by an integer amount of hours. The time of flights there and back may differ from each other not more than by 10 minutes.

The duration of a flight doesn‘t exceed 6 hours. The difference between airport local times is not greater than 5 hours.

Input

There are two lines, each of them contains two numbers. The first line consists of the departure time and the arrival time of the flight there, the second one — the departure and the arrival times of the back flight. Numbers in the lines are separated with a space, an amount of minutes is separated from an amount of hours with a point.

Output

Your program should write a non-negative integer (without extra zeroes) that corresponds to the difference in time between the two airports.

Sample

input output
23.42 00.39
08.10 17.11
4

Problem Author: Magaz Asanov & Stanislav Vasilyev
Problem Source: Ural State Univerisity Personal Contest Online February‘2001 Students Session

Tags: none  (hide tags for unsolved problems)

Difficulty: 585

题意:从一个地方到另一个地方去,再回来,中间有间隔。

给出去的和回来的起飞时间,降落时间。

问时差。

分析:暴力枚举。

  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 DAY = 24 * 60, MAXFLIGHT = 6 * 60, MAXDELTA = 5 * 60;
 52 int b1, e1, b2, e2;
 53
 54 inline int GetTime()
 55 {
 56     int x = Getint();
 57     int y = Getint();
 58     return x * 60 + y;
 59 }
 60
 61 inline void Input()
 62 {
 63     b1 = GetTime();
 64     e1 = GetTime();
 65     b2 = GetTime();
 66     e2 = GetTime();
 67 }
 68
 69 inline void Solve()
 70 {
 71     int ans = -INF;
 72     for(int flight = 0; flight <= MAXFLIGHT; flight++)
 73     {
 74         for(int delay = -MAXDELTA; delay <= MAXDELTA; delay++)
 75         {
 76             int x = b1;
 77             x = x + flight - delay;
 78             x = ((x % DAY) + DAY) % DAY;
 79             if(x != e1) continue;
 80
 81             x = b2;
 82             x = x + delay;
 83             int left = x + flight - 10, right = x + flight + 10;
 84             left = ((left % DAY) + DAY) % DAY;
 85             right = ((right % DAY) + DAY) % DAY;
 86             if(!(left <= e2 && e2 <= right)) continue;
 87
 88             ans = delay;
 89             break;
 90         }
 91         if(ans != -INF) break;
 92     }
 93
 94     printf("%.0lf\n", abs(ans) / 60.0);
 95 }
 96
 97 int main()
 98 {
 99     freopen("a.in", "r", stdin);
100     Input();
101     Solve();
102     return 0;
103 }

时间: 2024-10-11 23:20:35

ural 1070. Local Time的相关文章

ural 1073. Square Country

1073. Square Country Time limit: 1.0 secondMemory limit: 64 MB There live square people in a square country. Everything in this country is square also. Thus, the Square Parliament has passed a law about a land. According to the law each citizen of th

URAL 1099 Work scheduling 一般图的最大匹配 带花树算法(模板)

R - Work scheduling Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice URAL 1099 Description There is certain amount of night guards that are available to protect the local junkyard from possible junk r

ural 2030

Awesome Backup System Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice URAL 2030 Description It is known that all people can be divided into two groups: those who have never lost important data and t

深度学习主机环境配置: Ubuntu16.04 + GeForce GTX 1070 + CUDA8.0 + cuDNN5.1 + TensorFlow

深度学习主机环境配置: Ubuntu16.04 + GeForce GTX 1070 + CUDA8.0 + cuDNN5.1 + TensorFlow 最近在公司做深度学习相关的学习和实验,原来一直在自己的电脑上安装虚拟机跑,速度实在太慢,主机本身性能太弱,独显都没有,物理安装Ubuntu也没多大意义,所以考虑用公司性能最强悍的游戏主机(i7 6700+GTX 1070) 做实验,这台主机平时是用来跑HTC VIVE的,现在归我用了o(*≧▽≦)ツ. 原本以为整个一套安装下来会很顺利,一路火花

Petrozavodsk Winter-2013. Ural FU Contest Problem D. Five Palindromes manacher、一个串切割成5个回文子串、优化

Ural Federal University Contest, SKB Kontur Cup Petrozavodsk Winter Training Camp, Saturday, February 2, 2013 Problem D. Five Palindromes Input file: input.txt Output file: output.txt Time limit: 2 seconds (3 seconds for Java) Memory limit: 256 mebib

bzoj1814: Ural 1519 Formula 1 2011-12-20

1814: Ural 1519 Formula 1Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 263  Solved: 70[Submit][Status][Discuss]DescriptionRegardless of the fact, that Vologda could not get rights to hold the Winter Olympic games of 20**, it is well- known, that the 

URAL 1907. Coffee and Buns(数论推导+容斥原理)

1907. Coffee and Buns Time limit: 1.0 second Memory limit: 64 MB Planet Ataraxia is known for its education centers. The people who are expected to take high social positions in future are brought up in conditions of continuous training and supervisi

ural 1073. Square Country 完全背包

点击打开链接 1073. Square Country Time limit: 1.0 second Memory limit: 64 MB There live square people in a square country. Everything in this country is square also. Thus, the Square Parliament has passed a law about a land. According to the law each citiz

URAL 2026 Dean and Schedule 贪心、双端队列(deque)、队列(queue)

C - Dean and Schedule Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice URAL 2026 Description A new academic year approaches, and the dean must make a schedule of classes for first-year students. Ther