Miku

推一个小式子就知道了

计算出最后的位置,然后从后往前比较。

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long last[100001];
long long n,m;
long long x,y;
long long ans;
int main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%lld%lld",&x,&y);
		last[i]=x+y*m; 
	}
	ans++;
	for(int i=n-1;i>=1;i--){
		if(last[i]>=last[i+1]){
		//	ans++;
			last[i]=last[i+1]; 
		} 
		else{
			ans++;
		}
	} 
	cout<<ans;
	return 0;
} 

相关文章:

  • 2021-05-22
  • 2022-02-03
  • 2022-01-03
  • 2021-06-07
  • 2021-06-30
  • 2021-11-19
  • 2022-01-02
猜你喜欢
  • 2022-12-23
  • 2021-11-08
  • 2021-06-18
  • 2021-08-11
  • 2021-07-17
  • 2021-08-21
  • 2021-12-24
相关资源
相似解决方案