贪心,一边读入一边更新mn,用mn更新答案,mn每次加s

#include<iostream>
#include<cstdio>
using namespace std;
int n,s,mn=1e9;
long long ans;
int main()
{
	scanf("%d%d",&n,&s);
	for(int i=1,w,c;i<=n;i++)
	{
		scanf("%d%d",&w,&c);
	 	mn+=s;
		mn=min(mn,w);
	 	ans+=1ll*mn*c;
	}
	printf("%lld\n",ans);
	return 0;
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
  • 2021-06-11
  • 2021-11-15
  • 2021-11-29
  • 2021-08-05
  • 2021-12-14
猜你喜欢
  • 2021-12-21
  • 2022-12-23
  • 2021-07-27
  • 2021-05-23
  • 2022-12-23
  • 2022-01-08
  • 2021-09-29
相关资源
相似解决方案