您的位置:首页 > 其它

coderforce 588A Duff and Meat(简单的贪心)

2015-10-16 09:28 232 查看
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define LL long long
const LL maxm=1e5+10;
LL a[maxm],p[maxm];
int main()
{
LL n;
while(scanf("%lld",&n)!=EOF)
{
for(LL i=0;i<n;i++)
{
scanf("%lld%lld",&a[i],&p[i]);
}
LL sum=0;
for(LL i=0;i<n;)
{
LL cnt=0;
LL s=0;
for(LL j=i+1;j<n;j++)
{
if(p[i]<p[j])
{
cnt++;
s+=a[j];
}
else
{
break;
}
}
sum+=(a[i]+s)*p[i];
i+=(cnt+1);
}
printf("%lld\n",sum);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: