Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define MAX 2000000000000000007
- using namespace std;
- typedef long long ll;
- map<ll, ll> bit;
- void update(ll idx, ll val){
- idx = idx + 1LL;
- for(; idx <= MAX; idx += idx&(-idx)) {
- //cout << idx << endl;
- //string pluf; cin >> pluf;
- bit[idx] += val;
- }
- }
- ll query(ll idx){
- idx = idx + 1LL;
- ll sum = 0;
- for(; idx > 0; idx -= idx&(-idx)) {
- //cout << idx << endl;
- if(bit.count(idx)) sum += bit[idx];
- }
- return sum;
- }
- int main(){
- int n; scanf("%d", &n);
- ll past = 0;
- for(int i = 0; i < n; i++){
- ll x, y; scanf("%lld %lld", &x, &y);
- //cout << ((x+1LL)*(x+1LL)) << " " << ((y+1LL)*(y+1LL)) << endl;
- x = x + past;
- y = y + past;
- ll dist = x*x + y*y;
- //cout << dist << endl;
- past = query(dist);
- printf("%lld\n", past);
- //cout << "-------------\n";
- update(dist, 1);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement