跳到正文

个人记录

AC代码

#SUSPENDED#约 2 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年1月10日
篇幅
约 2 分钟

版本

  1. v1当前
C++
#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,T;
    cin>>n>>T;
    int p[n+1];
    for(int i=0;i<=n;i++) cin>>p[i];
    char t[n];
    for(int i=0;i<n;i++) cin>>t[i];
    double maxS=0,reqT=0,greenL=0;
    for(int i=0;i<n;i++)
	{
        int len=p[i+1]-p[i];
        double s;
        if(t[i]=='R') s=5;
        else if(t[i]=='B') s=3;
        else
		{
            s=0;
            greenL+=len;
            continue;
        }
        reqT+=len/s;
        if(s>maxS) maxS=s;
    }
    if(reqT>=T)
	{
        cout<<fixed<<setprecision(2)<<maxS<<endl;
        return 0;
    }
    if(greenL==0)
	{
        cout<<fixed<<setprecision(2)<<maxS<<endl;
        return 0;
    }
    double greenS=greenL/(T-reqT);
    double finalS=max(maxS,greenS);
    cout<<fixed<<setprecision(2)<<finalS;
    return 0;
}
原文