挖煤(coal)
2024-08-29 19:08:33
挖煤(coal)
solution
我好弱,啥也想不到。
想了很久dp,这有后效性啊。
结果倒着做就可以了,因为后面的不会影响前面的。
考虑前面的影响后面:挖煤相当于让后面所有a[I]*(1+k%)
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
int n,a[100005],op[100006];
double k,c,w,f[100005];
int main()
{
cin>>n>>k>>c>>w;
for(int i=1;i<=n;i++)scanf("%d%d",&op[i],&a[i]);
for(int i=n;i>=1;i--){
if(op[i]==1)f[i]=max(f[i+1],f[i+1]*(1-k/100)+a[i]);
else f[i]=max(f[i+1],f[i+1]*(1+c/100)-a[i]);
}
printf("%.2lf\n",f[1]*w);
return 0;
}
最新文章
- [转]如何在ASP.NET Core中实现一个基础的身份认证
- saltstack 入门命令
- GITHUB使用简介
- highchars
- NOIP2001 Car的旅行路线
- Ansj分词双数组Trie树实现与arrays.dic词典格式
- [zz]android的logcat详细用法
- java把InputStram 转换为String
- centos 下mysql操作
- 如何用C#把Doc文档转换成rtf格式
- eclipse 快捷方式大全
- Day 1: How to install jedi/codeintel plugin for sublime on Linux
- DB2的基础指令 学习笔记
- 《算法导论》习题2.3-6 改进的InsertSort
- Java常用集合体系以及相互区别
- Python可视化----------matplotlib.pylot
- Could not create pool connection. The DBMS driver exception was: null, message from server: ";Host &#39;192.168.XX.XX&#39; is blocked because of many connection errors; unblock with &#39;mysqladmin flush-hosts&#39;
- 使用VS+OpenCV调用深度学习模型
- laravel5的Bcrypt加密方式对系统保存密码的小结
- Java并发编程--6.Exchanger线程间交换数据
热门文章
- 机器学习中正则化项L1和L2的直观理解
- tk.mybatis Example 多个or条件拼接
- Java - 类加载的时候,是有缺省同步锁的
- 嵌入式开发 centos7 交叉编译环境准备
- python笔记-dict字典的方法
- PHP使用CURL_MULTI实现多线程采集
- spark入门: wordcount-java
- printf(";\033[1;33m ***** \033[0m \n";);
- POJ:2185-Milking Grid(KMP找矩阵循环节)
- greenplum-时间处理