QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#404595#2544. Flatland CurrencyZxc200611WA 43ms10404kbC++141.1kb2024-05-04 10:13:342024-05-04 10:13:35

Judging History

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

  • [2024-05-04 10:13:35]
  • 评测
  • 测评结果:WA
  • 用时:43ms
  • 内存:10404kb
  • [2024-05-04 10:13:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int inf=0x1f1f1f1f1f1f1f1f;
int n,c,c1,c5;
int f[2][410000];
vector<int> v[5];
signed main()
{
	cin>>n>>c;
	c5=c/5,c1=c%5;
	for(int i=0;i<=4;i++)
		v[i]=vector<int>({0});
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		int x5=(x+4)/5,x1=((-x)%5+5)%5;
		v[x1].push_back(x5);
	}
	for(int i=0;i<=4;i++)
		partial_sum(v[i].begin(),v[i].end(),v[i].begin());
	memset(f[1],0x1f,sizeof(f[1]));
	f[1][0]=0;
	for(int i=4;i>=1;i--)
	{
		if(v[i].size()==0)
			continue;
		// cout<<"i="<<i<<endl;
		memcpy(f[0],f[1],sizeof(f[0]));
		memset(f[1],0x1f,sizeof(f[1]));
		for(int r=0;r<i;r++)
		{
			for(int x=r,y=r;x<=4*n;x+=i)
			{
				while(((x-y)/i>(int)v[i].size()-1)||(y<x&&f[0][y+i]+v[i][(x-y-i)/i]<=f[0][y]+v[i][(x-y)/i]))
					y+=i;
				// cout<<"x="<<x<<" y="<<y<<" => "<<f[0][y]<<" + "<<v[i][(x-y)/i]<<endl;
				f[1][x]=min<int>(f[1][x],f[0][y]+v[i][(x-y)/i]);
			}
		}
		// for(int x=0;x<=4*n;x++)
		// 	cout<<"f "<<i<<" x="<<x<<" = "<<f[1][x]<<endl;
	}
	int ans=0;
	for(int x=0;x<=4*n;x++)
	{
		if(f[1][x]<=c5)
			ans=x;
	}
	cout<<ans+c1<<endl;
}

详细

Test #1:

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

input:

5 57
9 14 31 18 27

output:

8

result:

ok answer is '8'

Test #2:

score: 0
Accepted
time: 0ms
memory: 9992kb

input:

4 50
11 11 11 11

output:

12

result:

ok answer is '12'

Test #3:

score: 0
Accepted
time: 43ms
memory: 10380kb

input:

100000 89648823509660
921733427 402270498 51157221 585477094 435728758 913951087 580580944 557082810 585086423 837912728 799129405 867009344 751591136 714946046 464999915 256043168 416678301 183246216 569365122 479031618 435168577 31068363 903791719 497652990 960987871 223120213 395437892 112869678 ...

output:

200414

result:

ok answer is '200414'

Test #4:

score: -100
Wrong Answer
time: 42ms
memory: 10404kb

input:

99999 3234700062922
394766137 401419056 55997758 205712163 585962152 750591556 245421581 607883471 437707305 758188075 522354844 202404802 307099733 99935245 321784033 643800024 481548024 43007287 404431495 848761213 352455926 541535791 702868758 875691279 485597478 119612707 776231855 48839061 1144...

output:

6515

result:

wrong answer expected '61505', found '6515'