QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#559776 | #862. Social Justice | rotcar07 | WA | 3ms | 5636kb | C++20 | 1.1kb | 2024-09-12 09:19:23 | 2024-09-12 09:19:25 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int maxn=2e5+5;
int n;
typedef long long ll;
ll a[maxn],sum[maxn],p,q;
int id[maxn];
inline void solve(){
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i],id[i]=i;
sort(id+1,id+n+1,[&](int x,int y){return a[x]<a[y];});
sort(a+1,a+n+1);
for(int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
cin>>p>>q;
int mx=0,L=0,R=0;
for(int i=1;i<=n;i++){
int l=0,r=i-1;
auto chk=[&](int d){
return (sum[i]-sum[d])*p>=q*a[i]*(i-d);
};
while(l<r){
int mid=l+r>>1;
if(chk(mid)) r=mid;
else l=mid+1;
}
if(i-r>mx){
mx=i-r;L=r,R=i;
}
else if(i-r==mx){
R=i;
}
}
cout<<L+n-R<<'\n';
vector<int> v;
for(int i=1;i<=L;i++) v.push_back(id[i]);
for(int i=R+1;i<=n;i++) v.push_back(id[i]);
sort(v.begin(),v.end());
for(auto x:v) cout<<x<<' ';cout<<'\n';
}
int main(){
std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t;cin>>t;
while(t--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5580kb
input:
3 4 1 2 3 4 3 2 5 1 15 2 5 1 2 1 5 1 2 3 1000 10000 4 3
output:
0 1 2 2 4 5
result:
ok 6 numbers
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 5636kb
input:
1000 1 10 3 2 2 10 100 3 2 3 10 10 100 3 2 4 1 2 3 4 3 2 5 1 15 2 5 1 2 1 5 1 2 3 1000 10000 4 3 6 1 2 3 4 1000 10000 4 3 5 50000 2 1 1 5000 2 1 10 1 15 2 5 1 10000 1 1 1 1 2 1 20 1 15 2 5 1 10000 1 1 1 1 1 15 2 5 1 10000 1 1 1 1 2 1 25 1 15 2 5 1 10000 1 1 1 1 1 15 2 5 1 10000 1 1 1 1 1 15 2 5 1 2 ...
output:
0 0 1 3 0 1 2 2 4 5 3 1 5 6 2 1 5 3 2 4 6 6 2 4 6 12 14 16 8 2 4 6 12 14 16 22 24 13 1 2 3 4 5 6 7 8 9 10 11 12 20 15 1 2 3 4 5 6 7 8 9 10 11 12 18 19 20 0 0 1 12 0 10 1 4 5 6 7 13 14 15 18 20 1 16 1 18 1 13 10 4 5 6 9 11 15 16 18 19 20 0 0 1 10 0 10 1 2 4 6 8 9 11 13 18 20...
result:
wrong answer 69th numbers differ - expected: '2', found: '0'