QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#559802 | #862. Social Justice | rotcar07 | WA | 3ms | 5864kb | C++20 | 1.2kb | 2024-09-12 09:27:44 | 2024-09-12 09:27:46 |
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;
vector<pair<int,int>> sb;
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+1;
}
else if(i-r==mx){
if(l>=R) sb.emplace_back(R,l);
R=i+1;
}
}
vector<int> v;
for(auto [l,r]:sb) for(int i=l;i<=r;i++) v.push_back(id[i]);
for(int i=1;i<=L;i++) v.push_back(id[i]);
for(int i=R;i<=n;i++) v.push_back(id[i]);
sort(v.begin(),v.end());
cout<<v.size()<<'\n';
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: 1ms
memory: 5864kb
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: 5680kb
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 2 2 8 2 9 12 2 2 14 11 1 4 5 6 7 13 14 15 18 20 20 2 9 16 2 16 18 2 5 13 11 4 5 6 9 11 15 16 16 18 19 20 2 5 19 2 5 13 2...
result:
wrong answer 78th numbers differ - expected: '10', found: '11'