版本比较
题解:P14186 [USACO08MAR] Land Acquisition G(数据加强版)
正文
增加 6 行删除 6 行
9 行未改动1011121314141516171862 行未改动818283848585868788899090919293943 行未改动98991001011021021031041051061071081081091101111122 行未改动11511611711811911912012112212310 行未改动9 行未改动
参考代码:```cppsort(a + 1, a + 1 + n);
lst.push_back({0, V});for(int i = 1; i <= n; i++){ while(a[i].y >= lst.back().y) lst.pop_back(); lst.push_back(a[i]);62 行未改动int n; ll f[N];
struct pii{ ll x, y;
bool operator < (const pii & o) const{ return x < o.x; }} a[N]; vector<pii> lst;deque<pii> q; deque<pii> q;
ld get_k(ll ax, ll ay, ll bx, ll by){ return (ld)(ay - by) / (ax - bx);}3 行未改动 for(int i = 1; i <= n; i++){ cin >> a[i].x >> a[i].y; } sort(a + 1, a + 1 + n);
lst.push_back({0, V}); for(int i = 1; i <= n; i++){ while(a[i].y >= lst.back().y) lst.pop_back(); lst.push_back(a[i]); }
for(int i = 1; i < lst.size(); i++){ while(q.size() >= 2){ pii tp = q.back(); q.pop_back();2 行未改动 break; } } q.push_back((pii){lst[i].y, f[i-1]});
while(q.size() >= 2){ pii tp = q.front(); q.pop_front(); if(get_k(q.front().x, q.front().y, tp.x, tp.y) <= -lst[i].x){10 行未改动