QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#88217#2420. KitesurfingxiaoyaowudiWA 2ms3340kbC++141.1kb2023-03-15 17:00:492023-03-15 17:00:52

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:00:52]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3340kb
  • [2023-03-15 17:00:49]
  • 提交

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;
	for(int i(1);i<=n;++i) std::cin>>l[i]>>r[i];
	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);
				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);
			}
			f[j+1]=std::min(f[j+1],calc(ed[j+1]-pos)+f[i]+bs);
		}
	}
	std::cout<<f[n]<<std::endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3340kb

input:

10 4 5
0

output:

10

result:

ok single line: '10'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3276kb

input:

10 4 1
0

output:

3

result:

ok single line: '3'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3300kb

input:

10 4 3
0

output:

8

result:

ok single line: '8'

Test #4:

score: -100
Wrong Answer
time: 2ms
memory: 3304kb

input:

4 2 1
1
2 3

output:

3

result:

wrong answer 1st lines differ - expected: '2', found: '3'