QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#198086 | #6416. Classical Scheduling Problem | ucup-team870 | WA | 115ms | 12164kb | C++17 | 2.6kb | 2023-10-03 01:55:52 | 2023-10-03 01:55:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define IOS {cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);}
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define per(i,j,k) for(int i=j;i>=k;--i)
#define P pair<int,int>
#define ll long long
#define vi vector<int>
const int N=2e5+5;
struct {
int rt,ls[N*32],rs[N*32],num[N*32],top; ll sum[N*32];
void clear(){
rep(i,1,top){
ls[i]=rs[i]=num[i]=sum[i]=0;
}
top=0; rt=0;
}
int crt(int rt,int l,int r,int x){
int now=++top;
if(l==r){
num[now]=num[rt]+1; sum[now]=sum[rt]+x; return now;
}
int mid=l+r>>1;
if(mid>=x)ls[now]=crt(ls[rt],l,mid,x),rs[now]=rs[rt];
else rs[now]=crt(rs[rt],mid+1,r,x),ls[now]=ls[rt];
num[now]=num[ls[now]]+num[rs[now]]; sum[now]=sum[ls[now]]+sum[rs[now]];
return now;
}
void ins(int x){
rt=crt(rt,1,1e9,x);
}
void del(int rt,int l,int r,int x){
assert(rt);
sum[rt]-=x; --num[rt];
if(l==r)return;
int mid=l+r>>1;
if(mid>=x)del(ls[rt],l,mid,x);
else del(rs[rt],mid+1,r,x);
}
void del(int x){del(rt,1,1e9,x);}
ll qu(int rt,int l,int r,int k){
assert(k<=num[rt]);
if(l==r)return 1ll*k*l;
int mid=l+r>>1;
if(num[ls[rt]]>k)return qu(ls[rt],l,mid,k);
return qu(rs[rt],mid+1,r,k-num[ls[rt]])+sum[ls[rt]];
}
ll qu(int k){return qu(rt,1,1e9,k);}
}T1,T2;
int n;
struct info{
int a,b,idx;
bool operator < (const info&t)const &{
return b<t.b;
}
}q[N];
int res[N],cnt;
ll T;
info q1[N];
bool cmp(const info& a,const info& b){return a.a<b.a;}
void wk(int i,int v1,int v2){
cnt=0; assert(v1<=i && v2<=n-i);
rep(j,1,i)q1[j]=q[j];
sort(q1+1,q1+i+1,cmp);
rep(i,1,v1)res[++cnt]=q1[i].idx;
int top=0;
rep(j,i+1,n)q1[++top]=q[j];
sort(q1+1,q1+top+1,cmp);
rep(i,1,v2)res[++cnt]=q1[i].idx;
}
void slv(){
cnt=0;
cin>>n>>T;
rep(i,1,n)cin>>q[i].a>>q[i].b,q[i].idx=i;
sort(q+1,q+n+1);
int x=0,id=-1;
T1.clear(); T2.clear();
rep(i,1,n)T2.ins(q[i].a);
rep(i,1,n){
auto [a,b,_]=q[i];
T1.ins(a); T2.del(a);
while(x<i){
if(x+1<b-(n-i))break;
if(T1.qu(x+1)+T2.qu(b-(x+1))<=T)++x,id=i;
else break;
}
}
cnt=0;
if(id!=-1)wk(id,x,q[id].b-x);
cout<<x<<'\n'<<cnt<<'\n';
rep(i,1,cnt)cout<<res[i]<<' '; cout<<'\n';
}
signed main(){
IOS
int T;cin>>T;
while(T--)slv();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 11876kb
input:
2 4 100 20 1 40 4 60 3 30 3 1 5 10 1
output:
2 3 1 4 2 0 0
result:
ok ok, 2 test cases (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 115ms
memory: 12164kb
input:
10000 21 1892 174 13 604 15 170 2 413 11 899 2 531 12 651 17 553 9 429 8 837 14 937 12 577 7 532 11 19 2 173 10 165 6 762 15 221 6 945 13 302 19 7 3 54 26066 812 31 432 24 240 37 171 39 204 47 174 30 569 1 467 5 624 42 734 35 907 3 568 23 802 40 991 32 119 13 187 27 739 42 891 14 550 44 374 16 483 1...
output:
7 8 21 14 16 3 18 9 12 15 53 53 22 25 37 41 15 27 4 6 48 16 54 29 5 31 3 38 42 43 44 51 35 20 2 8 30 21 52 19 34 12 7 26 9 53 33 36 46 47 10 49 24 17 40 45 39 13 1 32 23 18 50 11 14 12 12 5 12 14 4 6 1 8 7 15 2 13 9 7 14 40 8 28 41 14 13 1 38 21 37 24 11 43 33 10 10 7 12 15 9 10 29 19 5 28 22 0...
result:
wrong answer too much time taken to learn the topics: 1233 > 1232 (test case 321)