QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#48540 | #3997. Candy Machine | _Vans_# | WA | 362ms | 11460kb | C++ | 998b | 2022-09-14 15:10:32 | 2022-09-14 15:10:33 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <unordered_map>
#include <iomanip>
#define pii pair<int,int>
#define ll long long
using namespace std;
const int MAXN=1e6+10;
const int INF=0x7fffffff;
ll a[MAXN];
long double sum=0;
int n=0;
int ans=0;
signed main()
{
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
cin>>n;
for(int i=0;i<n;i++) cin>>a[i];
sort(a,a+n);
for(int i=0;i<n;i++)
{
sum+=a[i];
}
for(int i=0;i<n;i++) if(a[i]>sum/n) ans++;
int now=ans,pre=0,back=n;
while(now>=pre && back>0)
{
pre=now;now=0;
int maxnum=a[--back];
sum-=maxnum;
for(int i=0;i<back;i++) if(a[i]>sum/back) now++;
ans=max(ans,max(now,pre));
}
cout<<ans<<endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 3612kb
input:
5 1 2 3 4 5
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3548kb
input:
18 3 5 5 1 2 2 3 9 2 2 7 1 7 3 2 3 6 6
output:
7
result:
ok single line: '7'
Test #3:
score: 0
Accepted
time: 3ms
memory: 3556kb
input:
20 170421784 139902913 635488787 31946330 289281525 541340761 264115901 680775011 102068389 128171044 636359374 477042327 879154459 716982403 654668380 256334408 874949295 737194459 663371810 549070350
output:
12
result:
ok single line: '12'
Test #4:
score: 0
Accepted
time: 167ms
memory: 11380kb
input:
1000000 97 83 13 77 44 47 43 74 81 97 76 62 55 12 85 74 75 59 45 81 1 36 26 28 32 64 72 100 78 52 60 31 81 48 78 91 68 2 35 45 98 51 48 99 74 7 13 43 22 4 68 62 29 31 11 66 77 63 1 64 61 72 74 26 91 37 86 50 91 6 18 69 87 87 51 62 61 59 29 69 20 2 70 84 31 56 12 21 9 48 2 61 11 21 8 38 17 28 78 87 3...
output:
500717
result:
ok single line: '500717'
Test #5:
score: 0
Accepted
time: 362ms
memory: 11460kb
input:
1000000 145493 170549 915888 2504 680394 758139 24665 365499 242644 535590 994789 297247 518365 834337 852392 945750 480961 126953 485671 11673 262033 473744 199902 743475 91856 394619 779195 616388 60537 756645 570144 510464 285494 932570 298148 627373 110058 469501 686867 559208 82153 90754 231338...
output:
500373
result:
ok single line: '500373'
Test #6:
score: 0
Accepted
time: 314ms
memory: 11428kb
input:
999999 138842067 7483867 621306163 351281546 595944065 95480114 365508036 751387459 56035370 757174318 169438287 638944328 172990655 762444787 884150457 284572671 788442934 321169997 239880233 764811445 554749447 207350825 203005320 577205786 687656367 676361754 130565640 256253378 854937392 1229058...
output:
500117
result:
ok single line: '500117'
Test #7:
score: 0
Accepted
time: 2ms
memory: 3556kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 7 3 2 3 6 6
output:
5
result:
ok single line: '5'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3448kb
input:
20 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 80 30 72 59 18
output:
5
result:
ok single line: '5'
Test #9:
score: -100
Wrong Answer
time: 1ms
memory: 3488kb
input:
20 1 3 6 3 4 10 7 7 7 4 4 2 4 3 6 671 623 686 378 833
output:
5
result:
wrong answer 1st lines differ - expected: '7', found: '5'