一直16分,请问哪位 大佬 能教教我,蒟蒻 万分感激
源代码 :
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <stdio.h>
#include <queue>
using namespace std ;
#define int long long
struct Node {
int xi ;
int ti ;
} x[10086];
int n , m ;
int ans ;
int adress ;
bool cmp (Node x , Node y) {
return x.ti < y.ti ;
}
signed main () {
cin >> n >> m ;
for(int i = 0 ; i < n ; i ++) {
cin >> x[i].xi >> x[i].ti ;
}
sort(x , x + n , cmp) ;
for(int i = 0 ; i < n ; i ++) {
x[i].ti += abs (adress - x[i].xi) ;
if(x[i].ti <= m) {
ans ++ ;
adress = x[i].xi ;
m -= x[i].ti ;
}
}
cout << ans << endl ;
return 0 ;
}
只有最后一个测试点过了
--P2107 小Z的AK计划