版本比较
题解 P1016 【旅行家的预算】
正文
增加 4 行删除 4 行
81 行未改动82838485868687888990919292939495964 行未改动10110210310410510510610710810918 行未改动1281291301311321321331341351369 行未改动81 行未改动```
Update: 时隔一年之后偶然翻到,竟然有137个赞QAQ!感谢大家,但由于之前的写法上有一些不足(太丑啦!),现在贴一份新的代码上来。
```cpp#include <bits/stdc++.h>using namespace std;#define maxn 100000#define db double#define INF 9999999 #define INF 9999999int n;db D1, D2, C, P, res, ans, maxx;
struct node4 行未改动}pl[maxn];
int Solve(int now){ int flag = INF; db d = pl[now].dis; int flag = INF; db d = pl[now].dis; for(int i = now + 1; i <= n && pl[i].dis - d <= maxx; i ++) { if(pl[i].co < pl[now].co) {18 行未改动int main(){ scanf("%lf%lf%lf%lf%d", &D1, &C, &D2, &P, &n); pl[0].dis = 0, pl[0].co = P; for(int i = 1; i <= n; i ++) for(int i = 1; i <= n; i ++) scanf("%lf%lf", &pl[i].dis, &pl[i].co); sort(pl, pl + n + 1); maxx = C * D2; int k = 0, t;9 行未改动