1 solutions
-
0
C++ :
#define MAXN 150010UL #define ll long long #include <algorithm> #include <cstdio> #include <queue> struct Point{ ll t1,t2; friend bool operator < (Point a,Point b){return a.t1<b.t1;} inline void in(){scanf("%lld%lld",&t1,&t2);return;} }; std::priority_queue<Point> que; Point s[MAXN]; int n,i; ll cur_time; inline bool comp(Point a,Point b){return a.t2<b.t2;} int main(){ scanf("%d",&n); for(;i<n;i++) s[i].in(); for(std::sort(s,s+n,comp),i=0;i<n;i++){ if(cur_time+s[i].t1<=s[i].t2) que.push(s[i]),cur_time+=s[i].t1; else if(s[i].t1<=que.top().t1&&cur_time+s[i].t1-que.top().t1<=s[i].t2) cur_time+=s[i].t1-que.top().t1,que.pop(),que.push(s[i]); } printf("%d",que.size()); return 0; }
- 1
Information
- ID
- 18544
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By