做网站大约需要多少钱,wordpress显示手动摘要,学网页制作的网站,做网站需要什么域名Contact ATC 我跑去列方程#xff0c; 然后就gg了。。。 我们计每个飞机最早到达时间为L[ i ], 最晚到达时间为R[ i ]#xff0c; 对于面对面飞行的一对飞机#xff0c; 只要他们的时间有交集则必定满足条件。 对于相同方向飞行的飞机#xff0c; 只有其中一个的时间包含另…Contact ATC 我跑去列方程 然后就gg了。。。 我们计每个飞机最早到达时间为L[ i ], 最晚到达时间为R[ i ] 对于面对面飞行的一对飞机 只要他们的时间有交集则必定满足条件。 对于相同方向飞行的飞机 只有其中一个的时间包含另一个的时间才满足条件。 #includebits/stdc.h
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PLL pairLL, LL
#define PLI pairLL, int
#define PII pairint, int
#define SZ(x) ((int)x.size())
#define ull unsigned long longusing namespace std;const int N 2e5 7;
const int inf 0x3f3f3f3f;
const LL INF 0x3f3f3f3f3f3f3f3f;
const int mod 1e9 7;
const double eps 1e-8;
const double PI acos(-1);struct Bit {int a[N];void init() {memset(a, 0, sizeof(a));}void modify(int x, int v) {for(int i x; i N; i i -i)a[i] v;}int sum(int x) {int ans 0;for(int i x; i; i - i -i)ans a[i];return ans;}int query(int L, int R) {if(L R) return 0;return sum(R) - sum(L - 1);}
};struct Node {Node(LL a, LL b) : a(a), b(b) {}bool operator (const Node rhs) const {return a * rhs.b rhs.a * b;}bool operator (const Node rhs) const {return a * rhs.b rhs.a * b;}void print() {printf(%.5f , 1.0 * a / b);}LL a, b;
};int n, w, x[N], v[N];
LL ans 0;
vectorPII vc[2];
vectorNode hs;
Bit bit;bool cmp(PII a, PII b) {if(a.fi b.fi) return a.se b.se;return a.fi b.fi;
}LL solve(vectorPII vc) {bit.init();LL ans 0;sort(vc.begin(), vc.end(), cmp);for(int i 0; i SZ(vc); i) {ans bit.sum(vc[i].se);bit.modify(vc[i].se, 1);}return ans;
}int main() {scanf(%d%d, n, w);for(int i 1; i n; i) {scanf(%d%d, x[i], v[i]);if(x[i] 0) {hs.push_back(Node(-x[i], v[i] w));hs.push_back(Node(-x[i], v[i] - w));} else {hs.push_back(Node(x[i], w - v[i]));hs.push_back(Node(x[i], -w - v[i]));}}sort(hs.begin(), hs.end());hs.erase(unique(hs.begin(), hs.end()), hs.end());for(int i 1; i n; i) {if(x[i] 0) {int L lower_bound(hs.begin(), hs.end(), Node(-x[i], v[i] w)) - hs.begin() 1;int R lower_bound(hs.begin(), hs.end(), Node(-x[i], v[i] - w)) - hs.begin() 1;vc[0].push_back(mk(L, R));} else {int L lower_bound(hs.begin(), hs.end(), Node(x[i], w - v[i])) - hs.begin() 1;int R lower_bound(hs.begin(), hs.end(), Node(x[i], -w - v[i])) - hs.begin() 1;vc[1].push_back(mk(L, R));}}ans solve(vc[0]);ans solve(vc[1]);ans 1ll * SZ(vc[0]) * SZ(vc[1]);bit.init();for(auto t : vc[1]) bit.modify(t.se, 1);for(auto t : vc[0]) ans - bit.sum(t.fi - 1);bit.init();for(auto t : vc[1]) bit.modify(t.fi, 1);for(auto t : vc[0]) ans - bit.query(t.se 1, N - 1);printf(%lld\n, ans);return 0;
}/*
*/ 转载于:https://www.cnblogs.com/CJLHY/p/10486254.html