Codeforces Round #443 (Div.2)
来源:互联网 发布:mac把照片导出到桌面 编辑:程序博客网 时间:2024/06/10 01:29
It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should first visit doctor 1, then doctor 2, then doctor 3 and so on). Borya will get the information about his health from the last doctor.
Doctors have a strange working schedule. The doctor i goes to work on the si-th day and works every di day. So, he works on days si, si + di, si + 2di, ....
The doctor's appointment takes quite a long time, so Borya can not see more than one doctor per day. What is the minimum time he needs to visit all doctors?
First line contains an integer n — number of doctors (1 ≤ n ≤ 1000).
Next n lines contain two numbers si and di (1 ≤ si, di ≤ 1000).
Output a single integer — the minimum day at which Borya can visit the last doctor.
32 21 22 2
4
210 16 5
11
In the first sample case, Borya can visit all doctors on days 2, 3 and 4.
In the second sample case, Borya can visit all doctors on days 10 and 11.
#include<iostream>#include<string.h>#include<stdio.h>using namespace std;#define LL long longLL n,s,d,now=0;int main(){ scanf("%lld",&n); for(int i=0;i<n;i++){ scanf("%lld%lld",&s,&d); if(now<s) now = s; else{ LL k = (now-s)/d; if(s+k*d<=now) k++; now = s+k*d; } } printf("%lld\n",now); return 0;}
- Codeforces Round #443 (Div. 2)
- Codeforces Round #443 (Div.2)
- Codeforces Round #443 (Div. 2)
- Codeforces Round #443 (Div.2)
- Codeforces Round #443 (Div.2)
- Codeforces Round #443(div 2)
- Codeforces Round #443 (Div. 2)
- Codeforces Round #443 (Div. 2)BTable Tennis
- Codeforces Round #443 (Div. 2) 总结
- Codeforces Round #443 (Div. 2) D,E
- [CF刷题]Codeforces Round #443 (Div. 2)
- Codeforces Round #443 (Div. 2) E. Tournament
- Codeforces Round #443 (Div. 2) 题解
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #104 (Div. 2)
- Codeforces Round #105 (Div. 2)
- 阿里云 安装mysql5.7.20
- poj 1679 The Unique MST
- jq:自定义事件
- Badboy自动化测试工具5 参数化 Add Variable
- python 具名元组
- Codeforces Round #443 (Div.2)
- webApi2--get与Post提交
- 科大讯飞:携手NVIDIA后,应用领域效率提升了50倍 | GTC 2017
- 图片文件批量重命名(Python)
- android--------Handler 消息传递机制
- maven是如何实现继承的
- SSL2796 2017年10月27日提高组 油滴拓展(贪心)
- 新智造对话信智资本陈可言:微软出来直接给钱
- “万物有声”智能语音解决方案发布会 | 预告