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; }
相关文章推荐
- mesos和Elasticsearch设计(Docker部署)(四)
- Oracle中创建dblink的方法
- 如何成为优秀的架构师
- 图片转换成data afn上传图片 图片转string
- HDU1034 Candy Sharing Game(java)
- git commit 代码时提示: Warning: Your console font probably doesn‘t support Unicode.
- iOS包管理工具——Cocoapods详解
- C语言项目二:电阻并联
- 从原理上搞定编码——BASE64编码
- AWK去重
- JSON.parse()和JSON.stringify()
- mipmap 文件的作用
- 团队精神
- Oracle 9i/10g Oracle越权修改SYS密码
- 贴一段代码出来
- JS生成36为UUID
- 读《大道至简——团队缺乏的不只是管理》有感
- java boolean的|=或&=或^=写法
- 第六周 项目4-数制转换
- 第6周 项目2-建立链栈算法库