delete pics to save space

This commit is contained in:
2023-08-03 09:22:52 +08:00
commit de60cd6ed4
1334 changed files with 66221 additions and 0 deletions

30
1.2365.cpp Normal file
View File

@ -0,0 +1,30 @@
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=5005;
int n,s;
int St[maxn],Sc[maxn],dp[maxn],q[maxn];
int main()
{
#ifdef local
freopen("pro.in","r",stdin);
#endif
scanf("%d%d",&n,&s);
for(int i=1;i<=n;i++)
{
int t,c; scanf("%d%d",&t,&c);
St[i]=St[i-1]+t;
Sc[i]=Sc[i-1]+c;
}
memset(dp,0x3f,sizeof(dp)); dp[0]=0;
int l=1,r=1;
for(int i=1;i<=n;i++)
{
while(l<r&&(dp[q[l+1]]-dp[q[l]])<=(s+St[i])*(Sc[q[l+1]]-Sc[q[l]])) l++;
dp[i]=dp[q[l]]-(s+St[i])*Sc[q[l]]+St[i]*Sc[i]+s*Sc[n];
while(l<r&&(dp[q[r]]-dp[q[r-1]])*(Sc[i]-Sc[q[r]])>=(dp[i]-dp[q[r]])*(Sc[q[r]]-Sc[q[r-1]])) r--;
q[++r]=i;
}
printf("%d\n",dp[n]);
return 0;
}