这份代码预计可以过 sub1&&sub2&&sub7&&sub8 ,但是只过了 sub1&&sub2 , sub7&&sub8 有 AC 和 WA 求调(请在 C++11 编译,不然不保证会不会 CE )
#include<bits/stdc++.h>
using namespace std;
int t,n;
struct node{
int a,b,c,d;
}prop[100005];
bool check(int mid){
for(register int i(1);i<=n;++i){
if(mid>=prop[i].a)
mid+=prop[i].c;
else return false;
}
return true;
}
int main(){
scanf("%d",&t);
if(t==1)
puts("0 0");
else if(t==2){
int n,a,b,c,d;
scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
printf("%d %d",a,b);
}else if(t==7||t==8){
int ans=2147483647;
scanf("%d",&n);
for(register int i(1);i<=n;++i)
scanf("%d%d%d%d",&prop[i].a,&prop[i].b,&prop[i].c,&prop[i].d);
sort(prop+1,prop+1+n,[](node x,node y)->bool{return x.a<y.a;});
int l=0,r=prop[n].a;
while(l<=r){
int mid=(l+r)/2;
if(check(mid)){
ans=mid;
r=mid-1;
}else l=mid+1;
}
printf("%d 0",ans);
}
return 0;
}