QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#22381 | #2544. Flatland Currency | George_Plover# | WA | 41ms | 5156kb | C++20 | 1.7kb | 2022-03-09 16:49:23 | 2022-04-30 00:58:52 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define MAXN 110000
#define LL long long
using namespace std;
int n;
LL m;
int a[MAXN];
int v[MAXN];
LL q[5][MAXN];
int loc[5];
int cnt[5];
int main()
{
scanf("%d%lld",&n,&m);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
if(a[i]%5)
{
v[i]=5-a[i]%5;
a[i]+=v[i];
q[v[i]][++loc[v[i]]]=a[i];
}
}
int ans=m%5;
m-=ans;
for(int i=1;i<=4;i++){
sort(q[i]+1,q[i]+loc[i]+1);
cnt[i]=1;
}
LL w=m;
while(1)
{
bool flag=0;
int num;
for(int i=1;i<=4;i++)
{
if(w<q[i][cnt[i]] || cnt[i]>loc[i])continue;
else if(!flag)
{
num=i;flag=1;
}
else if(1ll * i * q[num][cnt[num]] <= 1ll * num * q[i][cnt[i]])
{
num=i;
}
}
if(!flag)break;
w-=q[num][cnt[num]++];
}
for(int i=1;i<=4;i++)cnt[i]--;
for(int i=1;i<=4;i++)
for(int j=1;j<=loc[i];j++)
q[i][j]+=q[i][j-1];
int out=ans;
for(int i=max(cnt[1]-50,0);i<=min(cnt[1]+50,loc[1]);i++)
for(int j=max(cnt[2]-50,0);j<=min(cnt[2]+50,loc[2]);j++)
for(int k=max(cnt[3]-50,0);k<=min(cnt[3]+50,loc[3]);k++)
for(int l=max(cnt[4]-50,0);l<=min(cnt[4]+50,loc[4]);l++)
{
int v = i + 2*j +3*k +4*l;
LL sp = q[1][i] + q[2][j] + q[3][k] + q[4][l];
if(sp<=m)
out=max(out,ans+v);
}
cout<<out<<endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 3808kb
input:
5 57 9 14 31 18 27
output:
8
result:
ok answer is '8'
Test #2:
score: 0
Accepted
time: 3ms
memory: 3736kb
input:
4 50 11 11 11 11
output:
12
result:
ok answer is '12'
Test #3:
score: 0
Accepted
time: 25ms
memory: 5156kb
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: 41ms
memory: 5012kb
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:
11862
result:
wrong answer expected '61505', found '11862'