1004
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
struct note
{
double s,v,l;
} c[maxn];
int main()
{
int n;
while(~scanf("%d",&n))
{
for(int i=0; i<=n; i++)
scanf("%lf",&c[i].l);
for(int i=0; i<=n; i++)
scanf("%lf",&c[i].s);
for(int i=0; i<=n; i++)
scanf("%lf",&c[i].v);
double ans=0;
double len=0;
for(int i=0; i<=n; i++)
{
if(i!=0) len+=c[i].l;
double t=(c[i].s+len)/c[i].v;
ans=max(ans,t);
}
printf("%.10lf\n",ans);
}
}
1009
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
char s[maxn];
char ans[maxn];
int down[27],up[27];
int use[27];
int num[maxn][27];
queue<int> Q[30];
int main()
{
int k;
while(~scanf("%s%d",s+1,&k))
{
int len=strlen(s+1);
memset(num,0,sizeof(num));
memset(use,0,sizeof(use));
for(int i=1; i<=26; i++)
while(!Q[i].empty()) Q[i].pop();
for(int i=len; i>=1; i--)
{
int t=s[i]-'a'+1;
for(int j=1; j<=26; j++)
num[i][j]=num[i+1][j]+(j==t);
}
for(int i=1; i<=26; i++)
scanf("%d%d",&down[i],&up[i]);
for(int i=1; i<=len; i++)
{
int t=s[i]-'a'+1;
Q[t].push(i);
}
int pos=0;
int cnt=0;
for(int i=1; i<=k; i++)
{
for(int j=1; j<=26; j++)
{
if(use[j]==up[j]) continue;
while(!Q[j].empty()&&Q[j].front()<=pos) Q[j].pop();
if(!Q[j].empty())
{
int flag1=1;
int minn,maxx;
int now=Q[j].front();
minn=maxx=0;
use[j]++;
for(int k=1; k<=26; k++)
{
if(down[k]>num[now+1][k]+use[k])
flag1=0;
minn+=max(0,down[k]-use[k]);
maxx+=min(up[k]-use[k],num[now+1][k]);
}
if(minn>k-i||maxx<k-i)
flag1=0;
if(flag1)
{
pos=Q[j].front();
// printf("pos=%d\n",pos);
ans[++cnt]='a'+j-1;
break;
}
else
use[j]--;
}
}
}
if(cnt==k)
{
for(int i=1; i<=k; i++)
printf("%c",ans[i]);
}
else
printf("-1");
printf("\n");
}
}