QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#606743#2544. Flatland Currencygrass8cowWA 1ms5888kbC++17681b2024-10-03 11:56:082024-10-03 11:56:09

Judging History

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

  • [2024-10-03 11:56:09]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5888kb
  • [2024-10-03 11:56:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e7+5,e=1e-6;
int n,m,l,z,b,tot=1;
int a[N];
struct node{
	int w,v,id;
	double k;
}s[N];
bool cmp(node a,node b){
	if(fabs(a.k-b.k)<e)return a.w<b.w;
	return a.k<b.k;
}
signed main(){
	scanf("%lld%lld",&n,&m);
	b=m/5;
	z=5*b;
	l=m-z;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		s[i].id=i;
		int b=a[i]/5+1;
		if(a[i]%5==0)b--;
		s[i].w=5*b;
		s[i].v=s[i].w-a[i];
		s[i].k=(double)s[i].w/(double)s[i].v; 
	}
	sort(s+1,s+1+n,cmp);
	while(z){
		while(z<s[tot].w&&tot<=n)tot++;
		if(tot>n)break;
		l=l+s[tot].v;
		z=z-s[tot].w;
		tot++;
	}
	cout<<l;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 57
9 14 31 18 27

output:

7

result:

wrong answer expected '8', found '7'