cf 443(div2) 部分题目
http://codeforces.com/contest/879
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 3and 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.
3
2 2
1 2
2 2
4
2
10 1
6 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<bits/stdc++.h> using namespace std; #define MAXN 1000 char mp[1005][1005]; int Next[4][2]= {0,1,1,0,0,-1,-1,0},book[1000005][2],vis[1005][1005],n,m=0,a,b,sum; int main() { cin>>n; for(int i=0;i<n;i++) { cin>>a>>b; if(m<a) m=a; else if(m>=a) { while(m>=a) a+=b; m=a; } } cout<<m<<endl; return 0; }
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner.
For each of the participants, you know the power to play table tennis, and for all players these values are different. In a game the player with greater power always wins. Determine who will be the winner.
The first line contains two integers: n and k (2 ≤ n ≤ 500, 2 ≤ k ≤ 1012) — the number of people and the number of wins.
The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ n) — powers of the player. It's guaranteed that this line contains a valid permutation, i.e. all ai are distinct.
Output a single integer — power of the winner.
2 2
1 2
2
4 2
3 1 2 4
3
6 2
6 5 3 1 2 4
6
2 10000000000
2 1
2
Games in the second sample:
3 plays with 1. 3 wins. 1 goes to the end of the line.
3 plays with 2. 3 wins. He wins twice in a row. He becomes the winner.
题意 就是排队打球 限定回合数 找出在限定回合数内 最强的人
思路 这题最好别用队列做 我第一反应想这是个裸队列 随便写写就好了 结果花式gg 不如就用数组 记录k次下谁最大 而且 n<k 最大的一定是力量最大的 不然的话 如果一旦有人输了 那么他一定不会是最大 的 所以只需要维护一直在队列首的那个人的power就行了
#include<bits/stdc++.h> using namespace std; #define MAXN 1000 int Next[4][2]= {0,1,1,0,0,-1,-1,0},book[1000],n,x,y,s=0; long long int k; int a[1000]; int main() { cin>>n>>k; memset(book,0,sizeof(book)); for(int i=0; i<n; i++) cin>>a[i]; int p=a[0]; for(int i=1; i<n; i++) { if(s>=k) break; if(p>a[i]) s++; else { s=1; p=a[i]; } } cout<<p; return 0; }