P1233 木棍加工 题目链接:https://www.luogu.org/problem/P1233
参考博客:题解区第二个
#include <bits/stdc++.h>
using namespace std;
const int maxn=5e3+1;
int n,sum,temp;
struct thing
{
int lo,wi;
}t[maxn];
bool used[maxn];
bool comp(thing &a,thing &b)
{
if(a.lo==b.lo)return a.wi>b.wi;
return a.lo>b.lo;
}
int main()
{
ios::sync_with_stdio(0);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>t[i].lo>>t[i].wi;
}
sort(t+1,t+n+1,comp);
for(int i=1;i<=n;i++)
{
if(used[i]==0)
{
temp=t[i].wi;
for(int j=i+1;j<=n;j++)
{
if(t[j].wi<=temp&&used[j]==0)
{
used[j]=1;