0
已解决
朱优扬
中级天翼
中级天翼
#include <iostream>
#include <algorithm>
using namespace std;
struct lb{
int right,left;
}a[210];
int n,cnt,sum1,sum2;
bool cmp(lb x,lb y){
if(x.left!=y.left) return x.left<y.left;
return x.right<y.right;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i].left>>a[i].right;
sort(a+1,a+1+n,cmp);
for(int i=1;i<=n;i++){
if(a[i].left<sum1&&a[i].left<sum2) continue;
if(a[i].left>=sum1){
sum1+=(a[i].right-a[i].left);
cnt++;
}
else if(a[i].left>=sum2){
sum2+=(a[i].right-a[i].left);
cnt++;
}
}
cout<<cnt;
return 0;
}
哪错了?或给新思路
朱优扬在2021-03-26 22:13:54追加了内容
快!!!