| 比赛 |
2026.8.28 |
评测结果 |
WWWWWWWWWW |
| 题目名称 |
一周一次买下同班同学的那些事 |
最终得分 |
0 |
| 用户昵称 |
Ruyi |
运行时间 |
0.314 s |
| 代码语言 |
C++ |
内存使用 |
4.74 MiB |
| 提交时间 |
2026-08-28 12:58:51 |
显示代码纯文本
#include<bits/stdc++.h>
#define ll long long
#define N 200001
using namespace std;
ll t,n,a[N],sum[N],cnt=-1;
priority_queue<pair<ll,ll>> pq;
vector<ll> ans;
ll read(){
ll x=0,f=1;
char c=' ';
while(c>'9'||c<'0'){
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9'){
x=x*10+(c-'0');
c=getchar();
}
return x*f;
}
void write(ll x){
if(x<0){
putchar('-');
x=-x;
}
if(x>9) write(x/10);
putchar(x%10+'0');
return ;
}
int main(){
freopen("bought.in","r",stdin);
freopen("bought.out","w",stdout);
t=read();
while(t--){
n=read();
for(int i=1;i<=n;i++){
a[i]=read();
sum[i]=sum[i-1]+a[i];
}
for(int i=n;i>0;i--){
if(a[i]>0){
pq.push({-a[i],i});
if(cnt*sum[i-1]>-pq.top().first-5){
ans.push_back(pq.top().second);
pq.pop();
if(cnt==1) cnt=-1;
else cnt=1;
}
}
}
cout<<ans.size()<<endl;
for(auto i:ans) cout<<i<<' ';
cout<<endl;
ans.clear();
while(pq.size()) pq.pop();
}
return 0;
}