Questions surface: http://poj.org/problem?id=2376
And have different problems face luogu not ask the minimum price.
But ask minimum number of points.
Then it can be solved with a greedy.
code show as below:
#include<cstdio> #include<algorithm> #define int long long #define ll long long using namespace std; int n,ti; struct node{ int l,r; bool operator < (const node &a) const{ return l==a.l ? r<a.r : l<a.l; } }c[25010]; signed main() { scanf("%lld%lld",&n,&ti); for(int i=1;i<=n;i++) scanf("%lld%lld",&c[i].l,&c[i].r); sort(c+1,c+1+n); c[n+1].l=0x7fffffff; bool f=0; ll t=0,tp=0,ans=0; for(int i=1;i<=n;i++) if(c[i].l<=t+1){ if(c[i].r>tp) tpC = [I] .r, F = . 1 ; IF (C [I + . 1 ] .L> T + . 1 && F) // If not the next connection, then this must be taken. TP = T, ANS ++, F = 0 ; } IF (Ti> T) the printf ( " -1 \ n- " ); the else the printf ( " % LLD \ n- " , ANS); return 0 ; }