JRNTMRS - Journey to Mars

题意翻译

## 题目背景 已知火星一共有 n 个围成一圈的空间站,按顺时针顺序依次编号为 1,2,3...n。你可以从某一个空间站出发开始空间旅行。旅行需要消耗油料,一升的油料只能跑一公里。你的初始油量为 0  。每个空间站都能补给油料,你每到一个空间站(包括起点空间站),就可以把该空间站的油料全部拿走(你的油箱毫无容量限制)。如果你走着走着没油了,那么 你的空间旅行就会失败。给出所有相邻空间站的距离以及每个空间站能补给的油量。你需要确定从哪个空间站出发能够绕一圈回到该空间站,幸运的是,你可以选择 顺时针走,也可以选择逆时针走。 ## 输入格式 第一行是一个数 N; 接下来 N 行,每行两个整数 pi 和 di(保证pi≥0,di>0)分别表示第 i个空间站能补给的油量(单位:升)以及第 i 个空间站和第 i+1 个空间站的距离(单位:公里),由于是环状,dn 表示第 n 个空间站和第 1 个空间站的距离。 ## 输出格式 输出 n 行,如果第 i个空间站出发可以走遍所有空间站,则输出"TAK",否则输出“NIE”(均不包含引号)。 ## 样例输入 5 3 1 1 2 5 2 0 1 5 4 ## 样例输出 TAK NIE TAK NIE TAK

题目描述

Byteazar has decided on going to Mars to tour the space stations there being in existence. All marsian space stations lie on a circumference of a circle. Byteazar lands in one of them and then moves around by means of a special vehicle which is powered by an appropriate fuel. A litre of this fuel allows him to travel one meter. However, the provisions of the fuel are meagre, different quantities of it are available in each space station. Byteazar may refuel in the space station he is currently in, though he cannot get more fuel than it is available in that very place (the capacity of his fuel tank is unlimited). This quantity of fuel should allow him to reach the next space station. Byteazar has to decide where to land, so that he can visit all of the space stations. In the end he has to return to the space station in which he has landed. During his journey Byteazar has to travel on the circumference of the circle, constantly in one of the two possible directions. Task ---- Write a programme which: - reads from the standard input the number of space stations, distances between them and the amount of fuel available in each of them, - for each of the space stations checks, whether Byteazar can land there i.e. whether by starting in that very station and travelling in a freely chosen direction he is able to visit all of the space stations and return to his spaceship, - writes the outcome to the standard output. Input ----- The first line of the standard input contains a single integer ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/4f112c97919b1f496bfb5731a29c69f2ce2c6167.png) (![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/18bf1f9927d62452a14c8e3f1afd01f02f259090.png)). It denotes the number of space stations on Mars. The space stations are numbered from ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/17e23bd9f4448274b895d37e159cb09751fdf2de.png) to ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/4f112c97919b1f496bfb5731a29c69f2ce2c6167.png). In the next ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/4f112c97919b1f496bfb5731a29c69f2ce2c6167.png) lines there is a description of all of the stations and the distances between them. The ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/b877436e6a46244556896185103fbb281f6b6c7b.png)'st line contains two integers ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/b8d6419fb1914bbda9deeabc8c8eeca40e117c89.png) and ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/1d96ba5e0603bf41b4053c4c1174c50360450990.png) (![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/7942b051888d3f0bc556d382cd2dab50101372de.png), ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/ba9f3a147612a6c8024c5a136a364ef59c271682.png)). The first one denotes the amount of fuel (in litres) available in the ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/af121dc60b0f474c5ebf06392d630180cf0b86f7.png)'th space station. The other denotes the distance (in metres) between the ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/af121dc60b0f474c5ebf06392d630180cf0b86f7.png)'th and ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/b877436e6a46244556896185103fbb281f6b6c7b.png)'st space station (obviously ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/413e28eb8b699d38443dba840aa31d6a873cc891.png) denotes the distance between the ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/4f112c97919b1f496bfb5731a29c69f2ce2c6167.png)'th and the ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/17e23bd9f4448274b895d37e159cb09751fdf2de.png)st space station). The total amount of available fuel, as well as the sum of all distances between the space stations does not exceed ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/bef967db0abb57bb77165989140ef0d2c05dac4b.png). Output ------ The programme should write ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/4f112c97919b1f496bfb5731a29c69f2ce2c6167.png) lines to the standard output. The ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/af121dc60b0f474c5ebf06392d630180cf0b86f7.png)'th line should contain the word TAK (i.e. _yes_ is Polish), if Byteazar can land in the ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP9084/af121dc60b0f474c5ebf06392d630180cf0b86f7.png)'th space station or NIE (i.e. _no_ in Polish) when it is not possible. Example ------- For the input data: ``` 5 3 1 1 2 5 2 0 1 5 4 ``` the correct result is: ``` TAK NIE TAK NIE TAK ```

输入输出格式

输入格式


输出格式


输入输出样例

暂无测试点