hdu5477-模拟-A Sweet Journey
来源:互联网 发布:js缺少对象 编辑:程序博客网 时间:2024/06/01 09:50
https://vjudge.net/problem/HDU-5477
给定len长度的路,有n个区间,n个区间内每米要花费 x,其他地方要获得n,行走的过程中不能为负。问你最少需要带多少能量。
模拟。注意对开头的处理。
#include <bits/stdc++.h>using namespace std;vector<pair<int,int> >k;int main(){ int n,m,a1,b1,len,t; int a,b; //ios::sync_with_stdio(false); cin>>t; for(int tt=1;tt<=t;tt++){ cin>>m>>a1>>b1>>len; k.clear(); for(int i=0;i<m;i++){ cin>>a>>b; k.push_back(make_pair(a,b)); } //k.push_back(make_pair(b,len)); long long cost=0; int temp=0; long long all=0; for(int i=0;i<k.size();i++){ cost+=(k[i].first-temp)*b1; if(cost<(k[i].second-k[i].first)*a1) { all+=((k[i].second-k[i].first)*a1-cost); cost=0; } else { cost-=(k[i].second-k[i].first)*a1; } temp=k[i].second; } cout<<"Case #"<<tt<<": "<<all<<endl; } return 0;}
阅读全文
0 0
- HDU5477 A Sweet Journey 模拟
- hdu5477-模拟-A Sweet Journey
- hdu5477 A Sweet Journey(简单模拟)
- hdu5477 A Sweet Journey
- HDU5477 A Sweet Journey
- hdu5477 A Sweet Journey(水)
- HDOJ5477 A Sweet Journey(模拟)
- hdu 5477 A Sweet Journey 模拟
- A Sweet Journey
- A Sweet Journey
- A Sweet Journey
- A Sweet Journey 【二分】
- ACM--过沼泽--模拟--HDOJ 5477--A Sweet Journey
- HDU 5477: A Sweet Journey
- hdu 5477 A Sweet Journey
- HDU 5477 A Sweet Journey
- HDU 5477 A Sweet Journey
- HDU 5477 A Sweet Journey
- bootstrap开发小网页实例
- 分布式存储mogilefs
- python np.where()
- HTML-坐标的含义,以及变换的使用
- CodeArt入门教程(一)
- hdu5477-模拟-A Sweet Journey
- python常用模块(不定时更新)
- Linux字符设备驱动程序开发(3)-LED驱动程序设计
- 前端开发——HTML学习笔记
- Hive 与 Hbase的不同之处
- shell基础
- 【TC_SRM697 Hard】【JZOJ5180】ConnectedStates 题解
- 六月英语纪实
- 关于for循环的执行效率问题