见鬼了?!
  • 板块灌水区
  • 楼主xibaohe
  • 当前回复13
  • 已保存回复13
  • 发布时间2023/9/29 13:44
  • 上次更新2023/11/2 17:21:25
查看原帖
见鬼了?!
601747
xibaohe楼主2023/9/29 13:44

题目link

code:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<deque>
#include<map>
using namespace std;
#define int long long
#define endl '\n'
#define MAXN 10005
#define MAXM 1000005
int sh,sm,eh,em,n,dp[MAXN],t[MAXN],c[MAXN],p[MAXN],v[MAXM],w[MAXM],cnt,T;
void Ios()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.flags(ios::fixed);
   	cout.precision(6);
    return;
}
void Input()
{
	scanf("%d:%d%d:%d%d",&sh,&sm,&eh,&em,&n);
   	T=eh*60+em-sh*60-sm;
   	for(int i=1;i<=n;i++)
	{
		cin>>t[i]>>c[i]>>p[i];
		if(!p[i]) p[i]=999999;
	}
	return;
}
void Prepare()
{
	for(int i=1;i<=n;i++)
	{
		int u=1;
		while(p[i])
		{
			v[++cnt]=u*t[i];
			w[cnt]=u*c[i];
			p[i]-=u;
			u*=2;
			if(p[i]<u)
			{
				v[++cnt]=t[i]*p[i];
				w[cnt]=c[i]*p[i];
				break;
			}
		}
	}
	return;
}
void DP()
{
	for(int i=1;i<=cnt;i++)
		for(int j=T;j>=v[i];j--)
			dp[j]=max(dp[j],dp[j-v[i]]+w[i]);
	return;
}
void Output()
{
	cout<<dp[T]<<endl;
	return;
}
signed main(/*xibaohe_light*/)
{
	Ios();
	//freopen("flower.in","r",stdin);
	//freopen("flower.out","w",stdout); 
	Input();
   	Prepare();
   	DP();
   	Output();
	return 0;
}

本地运行(dev、xiaohoucode)可以正常输出,洛谷评测/IDE运行全都输出0?!

2023/9/29 13:44
加载中...