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 ...
随机推荐
- cocos代码研究(2)Layer学习笔记
auto layer = Layer::create(); /*************华丽分割线*************/ auto layer = LayerColor::create(Colo ...
- memcached小试牛刀
memcached安装 [root@localhost ~]# cd /usr/local/src [root@localhost src]#wget http://www.memcached.org ...
- Codeforces 1146E Hot is Cold
题意: 给出一个序列,有两种操作: \(>\;x\) 将大于\(x\)的数全都取负 \(<\;x\) 将小于\(x\)的数全都取负 最后输出序列中的所有数最后的状态 思路: 我们先考虑对于 ...
- 计算概论(A)/基础编程练习2(8题)/4:骑车与走路
#include<stdio.h> int main() { // 待处理的数据数量n ; scanf("%d", &n); float meters[n]; ...
- MySQL Crash Course #18# Chapter 26. Managing Transaction Processing
InnoDB 支持 transaction ,MyISAM 不支持. 索引: Changing the Default Commit Behavior SAVEPOINT 与 ROLLBACK TO ...
- P1350 车的放置
P1350 车的放置 设$f[i][j]$为当前推到第$i$列,该列高度$h$,已经放了$j$个车的方案数 则$f[i][j]=f[i-1][j]+f[i-1][j-1]*(h-j+1)$ 但是我们发 ...
- elasticsearch分词器ik
1. 下载和es配套的版本 git clone https://github.com/medcl/elasticsearch-analysis-ik 2. 编译 cd elasticsearch-an ...
- getContext,getApplicationContext和this有什么区别
使用this, 说明当前类是context的子类,一般是activity application等使用getApplicationContext 取得的是当前app所使用的application,这在 ...
- 如何修改ls命令列出来的目录颜色
答:默认为蓝色,在黑色背景下无法看清楚,因此以以下方法修改; 1.往~/.bash_profile文件中添加以下内容: export LS_COLORS='no=00:fi=00:di=01;33:l ...
- swift设计模式学习 - 原型模式
移动端访问不佳,请访问我的个人博客 设计模式学习的demo地址,欢迎大家学习交流 原型模式 用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象. 定义 用原型实例指定创建对象的种类,并且通 ...