QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#606743 | #2544. Flatland Currency | grass8cow | WA | 1ms | 5888kb | C++17 | 681b | 2024-10-03 11:56:08 | 2024-10-03 11:56:09 |
Judging History
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'