Codeforces 847H - Load Testing
思路:dp。
代码:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a) const int N=1e5+;
ll dp[N]={};
ll dp1[N]={};
ll a[N];
ll t[N]={};
ll t1[N]={};
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n;
cin>>n;
for(int i=;i<=n;i++)cin>>a[i]; t[]=a[];
for(int i=;i<=n;i++)
{
if(a[i]<=t[i-])
{
dp[i]=dp[i-]+t[i-]-a[i]+;
t[i]=t[i-]+;
}
else
{
t[i]=a[i];
dp[i]=dp[i-];
}
} t1[n]=a[n];
for(int i=n-;i>=;i--)
{
if(a[i]<=t1[i+])
{
dp1[i]=dp1[i+]+t1[i+]-a[i]+;
t1[i]=t1[i+]+;
}
else
{
t1[i]=a[i];
dp1[i]=dp1[i+];
}
} ll ans=min(dp1[],dp[n]);
for(int i=;i<=n-;i++)
ans=min(ans,dp1[i]+dp[i]-min(t[i],t1[i])+a[i]); cout<<ans<<endl;
return ;
}
Codeforces 847H - Load Testing的更多相关文章
- Difference Between Performance Testing, Load Testing and Stress Testing
http://www.softwaretestinghelp.com/what-is-performance-testing-load-testing-stress-testing/ Differen ...
- tsung: an open-source multi-protocol distributed load testing tool
ROPERTIES::type: KnowledgeBase_Cloud:END: 开源.多协议.分布式的压力测试工具 Item Summary tsung-recorder start 通过p ...
- [Windows Azure] Load Testing in Windows Azure
The primary goal of a load test is to simulate many users accessing a web application at the same ti ...
- Load Testing Socket.IO Web Applications and Infrastructure
转自:https://medium.com/better-programming/load-testing-socket-io-web-applications-and-infrastructure- ...
- Locust - A modern load testing framework https://locust.io/
Locust - A modern load testing frameworkhttps://locust.io/
- Google Code Jam 2010 Round 1C Problem B. Load Testing
https://code.google.com/codejam/contest/619102/dashboard#s=p1&a=1 Problem Now that you have won ...
- CodeForces 609C Load Balancing
先算出目标状态,然后拿当前状态与目标状态对比,即可算出答案 #include<cstdio> #include<cmath> #include<cstring> # ...
- Difference between Load / Stress / Performance Testing
Load and stress testing are subsets of performance testing. Performance testing means how best somet ...
- Understanding performance, load and stress testing
What are performance, load and stress testing? Performance testing, load testing and stress testing ...
随机推荐
- php开启mbstring扩展并设置支持utf-8编码
前一段时间使用一个服务的接口,因为调用接口时使用的参数里面有中文,调用接口会出现异常问题,后来才明白是编码不一致的问题.然而,我本地项目开发使用的是utf-8,接口那边也是需要utf-8的,那么问题来 ...
- liferay笑傲江湖-API之参数的工具类(ParamUtil)
public class ParamUtil { 036 037 public static boolean get( 038 HttpServletRequest request, String p ...
- pdo sqlserver
PHP代码如果想要用以上的方式兼容linux服务器和windows服务器,那么大概的示例代码是这样的. <?php header("Content-type: text/html; c ...
- 自动加载 autoload
自动加载 是什么时候调用的 是实例化某个对象的时候,在当前脚本中没有找到对应类的时候 ,如果当前找到了就不会调用__autoload方法 例如:例子一,找到类 <?php function _ ...
- Lower Power with CPF(四)
CPF从Front-end到Back-end(RTL--GDSII)的整个流程: 1)Creating a CPF file:来在前端就建立lower power的规范. 2)检查CPF文件的正确性, ...
- css3实现头像旋转360度
css样式: .div a img{ width: 88px; height: 88px; border-radius: 88px; transition: all 1.2s ease-out 0s; ...
- mysql事务(二)——控制语句使用
事务控制 一般来说,mysql默认开启了事务自动提交功能,每条sql执行都会提交事务.可以使用如下语句关闭事务自动提交功能. show session variables like 'autocomm ...
- python之路----初识面向对象(二)
类命名空间与对象.实例的命名空间 创建一个类就会创建一个类的名称空间,用来存储类中定义的所有名字,这些名字称为类的属性 而类有两种属性:静态属性和动态属性 静态属性就是直接在类中定义的变量 动态属性就 ...
- Linux下Oracle常用命令
1. 备份表 exp database_user/pass tables='(table1,table2)' file=filename.dmp(例如:exp ismrenbao/iflytek ta ...
- Centos下使用php调用shell脚本
我们在实际项目中或许会遇到php调用shell脚本的需求.下面就用简单案例在Centos环境下实践 准备 查看php.ini中配置是否打开安全模式 //php.ini safe_mode = //这个 ...