这题 本蒟蒻 已经 卡了 整整三天了 , 一直 93 分 , 第十一个测试点RE , 求 DADAO 帮忙看一下
C++小破源码 :
#include <iostream>
#include <algorithm>
using namespace std ;
#define int long long
#define re register
struct Node {
int road ;
int time ;
int fnl ;
}a[2000005];
int n , m ;
int ans ;
int last ;
int used_time ;
bool cmp (Node x , Node y) {
return x.fnl < y.fnl ;
}
signed main () {
cin >> n >> m ;
for(re int i = 1 ; i <= n ; i ++) {
cin >> a[i].road >> a[i].time ;
a[i].fnl = a[i].road + a[i].time ;
}
sort(a + 1 , a + n + 1 , cmp) ;
for(re int i = 1 ; ; i ++) {
if(used_time + a[i].fnl-last > m) {
cout << ans << endl ;
break ;
}else {
used_time += a[i].fnl - last ;
}
last = a[i].road ;
ans ++ ;
}
return 0 ;
}