CodeForces - 879A 2021.01.23 Rating赛

CodeForces - 879A 

#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define speed_up ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
/*
一道水题,看题意就能懂,第一次wa了因为写m>a没加等于号
*/
int main()
{
int n;
cin>>n;
int m=0;
for(int i=0;i<n;i++)
{
int a,b;
cin>>a>>b;
if(m<a)m=a;
else
{
while(m>=a)
{
a+=b;
}
m=a;
}

}
cout<<m<<endl;
}

 CodeForces - 879B 

#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define speed_up ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
/*
注意是一个人连赢k场
x初值为下标0的值
3 1 4 2 5 初始
1移到最后 x初值为3
3 4 2 5 1 第一次 kk=1
3移到最后 x变成4
4 2 5 1 3 第二次 kk=0
2移到最后 x不变
4 5 1 3 2 第三次 kk=1
4移到最后 x变成5
5 1 3 2 4 第四次 kk=0
*/
int main()
{
ll n,k,x;
cin>>n>>k;
ll a[n];
ll kk=0;
int f=0;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
x=a[0];
for(int i=1;i<n;i++)
{
if(kk>=k)
{
cout<<x<<endl;
f=1;
break;
}
if(x<=a[i])
{
x=a[i];
kk=1;
}
else kk++;
}
if(f==0)
{
cout<<x<<endl;
}
}

posted @ 2021-01-27 16:37  SyrupWRLD  阅读(94)  评论(0)    收藏  举报