QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#88221#2420. KitesurfingxiaoyaowudiWA 1ms3304kbC++141.2kb2023-03-15 17:24:042023-03-15 17:24:07

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-15 17:24:07]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3304kb
  • [2023-03-15 17:24:04]
  • 提交

answer

#include <algorithm>
#include <iostream>
constexpr int N(510);
using ll=long long;
constexpr ll inf(1e18);
ll s,d,t,l[N],r[N],ed[N];int n;
ll calc(ll k)
{
	if(k<0) return 0;
	ll q=k/d;
	return std::min(k,std::min(t*q+k-d*q,t*(q+1)));
}
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cin>>s>>d>>t;
	std::cin>>n;++n;s+=d;
	for(int i(2);i<=n;++i) std::cin>>l[i]>>r[i],l[i]+=d,r[i]+=d;
	l[0]=0;r[0]=d;
	l[n+1]=s;r[n+1]=s+d;++n;r[n+1]=inf;l[n+1]=inf;
	for(int i(1);i<=n;++i)
	{
		ed[i]=r[i]-d;
		if(ed[i]<=0)
		{
			ed[i]=0;
		}
		else
		{
			int t(0);
			while(l[t]<ed[i]) ++t;
			--t;ed[i]=std::max(r[t],ed[i]);
		}
	}
	static ll f[N];
	f[1]=calc(ed[1]);for(int i(2);i<=n;++i) f[i]=inf;
	for(int i(1);i<n;++i)
	{
		// std::cout<<f[i]<<" ";
		ll bs(0),pos(ed[i]);
		for(int j(i);j<n;++j)
		{
			if(pos<r[j])
			{
				ll k((r[j]-pos-1)/d+1);
				// std::cerr<<k<<std::endl;
				pos+=(k-1)*d;pos=std::min(pos,l[j]);pos+=d;
				bs+=k*t;
				int t(j);while(r[t]<=pos) ++t;pos=std::min(l[t],pos);
			}
			// std::cerr<<pos<<std::endl;
			f[j+1]=std::min(f[j+1],calc(ed[j+1]-pos)+f[i]+bs);
		}
	}
	std::cout<<f[n]-t<<std::endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3304kb

input:

10 4 5
0

output:

9

result:

wrong answer 1st lines differ - expected: '10', found: '9'