QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#427567#8775. MountainCraftucup-team1134#AC ✓391ms39428kbC++2315.5kb2024-06-01 13:53:482024-06-01 13:53:49

Judging History

你现在查看的是最新测评结果

  • [2024-06-01 13:53:49]
  • 评测
  • 测评结果:AC
  • 用时:391ms
  • 内存:39428kb
  • [2024-06-01 13:53:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005;
const ll INF=15LL<<58;

// BIT セグ木 遅延セグ木 のみ

// from: https://gist.github.com/yosupo06/ddd51afb727600fd95d9d8ad6c3c80c9
// (based on AtCoder STL)

#include <algorithm>
#include <array>
#ifdef _MSC_VER
#include <intrin.h>
#endif
namespace atcoder {
    namespace internal {
        int ceil_pow2(int n) {
            int x = 0;
            while ((1U << x) < (unsigned int)(n)) x++;
            return x;
        }
        int bsf(unsigned int n) {
#ifdef _MSC_VER
            unsigned long index;
            _BitScanForward(&index, n);
            return index;
#else
            return __builtin_ctz(n);
#endif
        }
    }  // namespace internal
    
}  // namespace atcoder

#include <cassert>
#include <numeric>
#include <type_traits>

namespace atcoder {
    
    namespace internal {
        
#ifndef _MSC_VER
        template <class T>
        using is_signed_int128 =
        typename std::conditional<std::is_same<T, __int128_t>::value ||
        std::is_same<T, __int128>::value,
        std::true_type,
        std::false_type>::type;
        
        template <class T>
        using is_unsigned_int128 =
        typename std::conditional<std::is_same<T, __uint128_t>::value ||
        std::is_same<T, unsigned __int128>::value,
        std::true_type,
        std::false_type>::type;
        
        template <class T>
        using make_unsigned_int128 =
        typename std::conditional<std::is_same<T, __int128_t>::value,
        __uint128_t,
        unsigned __int128>;
        
        template <class T>
        using is_integral = typename std::conditional<std::is_integral<T>::value ||
        is_signed_int128<T>::value ||
        is_unsigned_int128<T>::value,
        std::true_type,
        std::false_type>::type;
        
        template <class T>
        using is_signed_int = typename std::conditional<(is_integral<T>::value &&
                                                         std::is_signed<T>::value) ||
        is_signed_int128<T>::value,
        std::true_type,
        std::false_type>::type;
        
        template <class T>
        using is_unsigned_int =
        typename std::conditional<(is_integral<T>::value &&
                                   std::is_unsigned<T>::value) ||
        is_unsigned_int128<T>::value,
        std::true_type,
        std::false_type>::type;
        
        template <class T>
        using to_unsigned = typename std::conditional<
        is_signed_int128<T>::value,
        make_unsigned_int128<T>,
        typename std::conditional<std::is_signed<T>::value,
        std::make_unsigned<T>,
        std::common_type<T>>::type>::type;
        
#else
        
        template <class T> using is_integral = typename std::is_integral<T>;
        
        template <class T>
        using is_signed_int =
        typename std::conditional<is_integral<T>::value && std::is_signed<T>::value,
        std::true_type,
        std::false_type>::type;
        
        template <class T>
        using is_unsigned_int =
        typename std::conditional<is_integral<T>::value &&
        std::is_unsigned<T>::value,
        std::true_type,
        std::false_type>::type;
        
        template <class T>
        using to_unsigned = typename std::conditional<is_signed_int<T>::value,
        std::make_unsigned<T>,
        std::common_type<T>>::type;
        
#endif
        
        template <class T>
        using is_signed_int_t = std::enable_if_t<is_signed_int<T>::value>;
        
        template <class T>
        using is_unsigned_int_t = std::enable_if_t<is_unsigned_int<T>::value>;
        
        template <class T> using to_unsigned_t = typename to_unsigned<T>::type;
        
    }  // namespace internal
    
}  // namespace atcoder

#include <cassert>
#include <vector>

namespace atcoder {
    
    template <class T> struct fenwick_tree {
        using U = internal::to_unsigned_t<T>;
        
    public:
        fenwick_tree() : _n(0) {}
        fenwick_tree(int n) : _n(n), data(n) {}
        
        void add(int p, T x) {
            assert(0 <= p && p < _n);
            p++;
            while (p <= _n) {
                data[p - 1] += U(x);
                p += p & -p;
            }
        }
        
        T sum(int l, int r) {
            assert(0 <= l && l <= r && r <= _n);
            return sum(r) - sum(l);
        }
        
    private:
        int _n;
        std::vector<U> data;
        
        U sum(int r) {
            U s = 0;
            while (r > 0) {
                s += data[r - 1];
                r -= r & -r;
            }
            return s;
        }
    };
    
}  // namespace atcoder


#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
namespace atcoder {
    
    template <class S,
    S (*op)(S, S),
    S (*e)(),
    class F,
    S (*mapping)(F, S),
    F (*composition)(F, F),
    F (*id)()>
    struct lazy_segtree {
    public:
        lazy_segtree() : lazy_segtree(0) {}
        lazy_segtree(int n) : lazy_segtree(std::vector<S>(n, e())) {}
        lazy_segtree(const std::vector<S>& v) : _n(int(v.size())) {
            log = internal::ceil_pow2(_n);
            size = 1 << log;
            d = std::vector<S>(2 * size, e());
            lz = std::vector<F>(size, id());
            for (int i = 0; i < _n; i++) d[size + i] = v[i];
            for (int i = size - 1; i >= 1; i--) {
                update(i);
            }
        }
        
        void set(int p, S x) {
            assert(0 <= p && p < _n);
            p += size;
            for (int i = log; i >= 1; i--) push(p >> i);
            d[p] = x;
            for (int i = 1; i <= log; i++) update(p >> i);
        }
        
        S get(int p) {
            assert(0 <= p && p < _n);
            p += size;
            for (int i = log; i >= 1; i--) push(p >> i);
            return d[p];
        }
        
        S prod(int l, int r) {
            assert(0 <= l && l <= r && r <= _n);
            if (l == r) return e();
            
            l += size;
            r += size;
            
            for (int i = log; i >= 1; i--) {
                if (((l >> i) << i) != l) push(l >> i);
                if (((r >> i) << i) != r) push(r >> i);
            }
            
            S sml = e(), smr = e();
            while (l < r) {
                if (l & 1) sml = op(sml, d[l++]);
                if (r & 1) smr = op(d[--r], smr);
                l >>= 1;
                r >>= 1;
            }
            
            return op(sml, smr);
        }
        
        S all_prod() { return d[1]; }
        
        void apply(int p, F f) {
            assert(0 <= p && p < _n);
            p += size;
            for (int i = log; i >= 1; i--) push(p >> i);
            d[p] = mapping(f, d[p]);
            for (int i = 1; i <= log; i++) update(p >> i);
        }
        void apply(int l, int r, F f) {
            assert(0 <= l && l <= r && r <= _n);
            if (l == r) return;
            
            l += size;
            r += size;
            
            for (int i = log; i >= 1; i--) {
                if (((l >> i) << i) != l) push(l >> i);
                if (((r >> i) << i) != r) push((r - 1) >> i);
            }
            
            {
                int l2 = l, r2 = r;
                while (l < r) {
                    if (l & 1) all_apply(l++, f);
                    if (r & 1) all_apply(--r, f);
                    l >>= 1;
                    r >>= 1;
                }
                l = l2;
                r = r2;
            }
            
            for (int i = 1; i <= log; i++) {
                if (((l >> i) << i) != l) update(l >> i);
                if (((r >> i) << i) != r) update((r - 1) >> i);
            }
        }
        
        template <bool (*g)(S)> int max_right(int l) {
            return max_right(l, [](S x) { return g(x); });
        }
        template <class G> int max_right(int l, G g) {
            assert(0 <= l && l <= _n);
            assert(g(e()));
            if (l == _n) return _n;
            l += size;
            for (int i = log; i >= 1; i--) push(l >> i);
            S sm = e();
            do {
                while (l % 2 == 0) l >>= 1;
                if (!g(op(sm, d[l]))) {
                    while (l < size) {
                        push(l);
                        l = (2 * l);
                        if (g(op(sm, d[l]))) {
                            sm = op(sm, d[l]);
                            l++;
                        }
                    }
                    return l - size;
                }
                sm = op(sm, d[l]);
                l++;
            } while ((l & -l) != l);
            return _n;
        }
        
        template <bool (*g)(S)> int min_left(int r) {
            return min_left(r, [](S x) { return g(x); });
        }
        template <class G> int min_left(int r, G g) {
            assert(0 <= r && r <= _n);
            assert(g(e()));
            if (r == 0) return 0;
            r += size;
            for (int i = log; i >= 1; i--) push((r - 1) >> i);
            S sm = e();
            do {
                r--;
                while (r > 1 && (r % 2)) r >>= 1;
                if (!g(op(d[r], sm))) {
                    while (r < size) {
                        push(r);
                        r = (2 * r + 1);
                        if (g(op(d[r], sm))) {
                            sm = op(d[r], sm);
                            r--;
                        }
                    }
                    return r + 1 - size;
                }
                sm = op(d[r], sm);
            } while ((r & -r) != r);
            return 0;
        }
        
    private:
        int _n, size, log;
        std::vector<S> d;
        std::vector<F> lz;
        
        void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
        void all_apply(int k, F f) {
            d[k] = mapping(f, d[k]);
            if (k < size) lz[k] = composition(f, lz[k]);
        }
        void push(int k) {
            all_apply(2 * k, lz[k]);
            all_apply(2 * k + 1, lz[k]);
            lz[k] = id();
        }
    };
    
}  // namespace atcoder

#include <algorithm>
#include <cassert>
#include <vector>

namespace atcoder {
    
    template <class S, S (*op)(S, S), S (*e)()> struct segtree {
    public:
        segtree() : segtree(0) {}
        segtree(int n) : segtree(std::vector<S>(n, e())) {}
        segtree(const std::vector<S>& v) : _n(int(v.size())) {
            log = internal::ceil_pow2(_n);
            size = 1 << log;
            d = std::vector<S>(2 * size, e());
            for (int i = 0; i < _n; i++) d[size + i] = v[i];
            for (int i = size - 1; i >= 1; i--) {
                update(i);
            }
        }
        
        void set(int p, S x) {
            assert(0 <= p && p < _n);
            p += size;
            d[p] = x;
            for (int i = 1; i <= log; i++) update(p >> i);
        }
        
        S get(int p) {
            assert(0 <= p && p < _n);
            return d[p + size];
        }
        
        S prod(int l, int r) {
            assert(0 <= l && l <= r && r <= _n);
            S sml = e(), smr = e();
            l += size;
            r += size;
            
            while (l < r) {
                if (l & 1) sml = op(sml, d[l++]);
                if (r & 1) smr = op(d[--r], smr);
                l >>= 1;
                r >>= 1;
            }
            return op(sml, smr);
        }
        
        S all_prod() { return d[1]; }
        
        template <bool (*f)(S)> int max_right(int l) {
            return max_right(l, [](S x) { return f(x); });
        }
        template <class F> int max_right(int l, F f) {
            assert(0 <= l && l <= _n);
            assert(f(e()));
            if (l == _n) return _n;
            l += size;
            S sm = e();
            do {
                while (l % 2 == 0) l >>= 1;
                if (!f(op(sm, d[l]))) {
                    while (l < size) {
                        l = (2 * l);
                        if (f(op(sm, d[l]))) {
                            sm = op(sm, d[l]);
                            l++;
                        }
                    }
                    return l - size;
                }
                sm = op(sm, d[l]);
                l++;
            } while ((l & -l) != l);
            return _n;
        }
        
        template <bool (*f)(S)> int min_left(int r) {
            return min_left(r, [](S x) { return f(x); });
        }
        template <class F> int min_left(int r, F f) {
            assert(0 <= r && r <= _n);
            assert(f(e()));
            if (r == 0) return 0;
            r += size;
            S sm = e();
            do {
                r--;
                while (r > 1 && (r % 2)) r >>= 1;
                if (!f(op(d[r], sm))) {
                    while (r < size) {
                        r = (2 * r + 1);
                        if (f(op(d[r], sm))) {
                            sm = op(d[r], sm);
                            r--;
                        }
                    }
                    return r + 1 - size;
                }
                sm = op(d[r], sm);
            } while ((r & -r) != r);
            return 0;
        }
        
    private:
        int _n, size, log;
        std::vector<S> d;
        
        void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
    };
    
}  // namespace atcoder

using T=pair<ll,ll>;
using E=ll;

T f(T a,T b){
    if(a.fi==b.fi){
        return mp(a.fi,a.se+b.se);
    }else{
        return min(a,b);
    }
}

T g(E a,T b){
    return mp(b.fi+a,b.se);
}

E h(E a,E b){
    return a+b;
}

T ti(){
    return mp(INF,0);
}

E ei(){
    return 0;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,W;cin>>N>>W;
    vector<pair<ll,ll>> S(N);
    vector<ll> L(N),R(N),use={0,W};
    
    for(int i=0;i<N;i++){
        ll a,b;cin>>a>>b;
        S[i]=mp(a,b);
        L[i]=max(0LL,a-b);
        R[i]=min(W,a+b);
        use.push_back(L[i]);
        use.push_back(R[i]);
    }
    sort(all(use));
    use.erase(unique(all(use)),use.end());
    
    vector<T> def(si(use));
    for(int i=0;i+1<si(use);i++){
        def[i]=mp(0,use[i+1]-use[i]);
    }
    
    atcoder::lazy_segtree<T,f,ti,E,g,h,ei> seg(def);
    
    set<pair<ll,ll>> SE;
    
    for(int i=0;i<N;i++){
        int l=lower_bound(all(use),L[i])-use.begin();
        int r=lower_bound(all(use),R[i])-use.begin();
        if(SE.count(S[i])){
            seg.apply(l,r,-1);
            SE.erase(S[i]);
        }else{
            seg.apply(l,r,1);
            SE.insert(S[i]);
        }
        
        ll ans=W-seg.all_prod().se;
        
        double anss=ans;anss*=sqrt(2);
        
        cout<<fixed<<setprecision(20)<<anss<<"\n";
    }
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3836kb

input:

3 10
3 2
7 3
9 6

output:

5.65685424949238058190
12.72792206135785697541
12.72792206135785697541

result:

ok 3 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3784kb

input:

5 100
31 41
59 26
31 41
59 26
31 41

output:

101.82337649086285580324
120.20815280171308359058
73.53910524340095378193
0.00000000000000000000
101.82337649086285580324

result:

ok 5 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

100 10
6 4
2 3
7 6
5 5
3 6
7 5
5 8
10 4
9 8
0 9
9 10
9 3
2 3
10 10
8 4
10 9
0 1
1 7
0 2
3 4
10 3
3 10
7 4
7 5
1 4
0 7
1 9
5 6
8 8
7 4
8 1
3 9
2 1
5 5
2 1
10 9
8 4
0 9
10 7
4 1
9 10
8 6
5 4
1 4
0 9
9 3
4 8
5 10
7 2
8 10
7 10
3 4
2 2
8 5
0 9
5 3
1 4
6 4
0 3
8 1
1 6
3 8
8 4
6 5
10 2
2 2
8 4
6 1
2 4
6 4...

output:

11.31370849898476116380
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.142135623...

result:

ok 100 numbers

Test #4:

score: 0
Accepted
time: 1ms
memory: 4032kb

input:

1000 100
95 8
54 8
64 96
47 34
77 47
99 91
45 70
8 6
64 84
48 42
53 14
73 66
38 27
6 52
19 75
33 39
6 24
37 80
27 45
96 48
55 95
67 1
23 78
40 4
76 7
77 22
4 47
41 31
60 54
96 37
79 52
63 40
7 92
17 7
74 12
93 16
87 5
67 43
60 29
71 58
52 41
53 84
38 2
46 87
13 54
54 14
16 93
57 7
91 98
31 23
70 3
9...

output:

18.38477631085023844548
41.01219330881976077308
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
14...

result:

ok 1000 numbers

Test #5:

score: 0
Accepted
time: 1ms
memory: 3880kb

input:

1000 1000
942 407
513 739
329 437
605 318
847 416
128 543
588 237
903 365
703 556
313 928
621 344
974 444
780 265
993 889
103 427
94 977
897 586
566 326
785 938
224 952
150 441
716 802
729 584
954 347
640 4
91 633
738 970
823 253
158 890
115 734
327 391
554 258
373 67
396 995
788 73
609 703
627 801
...

output:

657.60930650348927883897
1414.21356237309510106570
1414.21356237309510106570
1414.21356237309510106570
1414.21356237309510106570
1414.21356237309510106570
1414.21356237309510106570
1414.21356237309510106570
1414.21356237309510106570
1414.21356237309510106570
1414.21356237309510106570
1414.2135623730...

result:

ok 1000 numbers

Test #6:

score: 0
Accepted
time: 152ms
memory: 14492kb

input:

200000 10
6 4
4 9
7 9
6 2
0 7
6 7
4 8
10 5
7 8
5 4
3 6
5 9
0 9
7 3
8 2
8 6
5 9
5 10
4 9
0 3
10 5
3 9
7 2
2 3
9 7
5 6
1 7
0 4
9 6
4 7
3 8
6 4
2 7
0 6
8 3
6 2
8 10
1 6
0 4
6 1
3 3
5 8
9 7
8 7
1 10
6 2
1 8
8 6
6 1
6 3
0 6
6 1
5 6
1 1
6 4
7 9
3 5
10 6
2 8
6 7
7 3
6 8
8 5
9 7
4 5
6 4
5 10
8 6
8 5
4 6
4 6...

output:

11.31370849898476116380
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.14213562373095101066
14.142135623...

result:

ok 200000 numbers

Test #7:

score: 0
Accepted
time: 195ms
memory: 13712kb

input:

200000 100
96 9
26 82
73 33
12 92
13 77
87 2
23 79
41 91
75 28
6 45
42 81
27 51
7 64
80 90
27 65
77 72
54 60
79 8
10 61
46 15
65 16
75 95
65 4
89 38
42 74
96 63
48 87
39 78
2 59
36 48
36 66
12 75
44 45
80 86
79 99
26 30
29 54
39 44
7 27
99 23
41 76
23 71
76 51
90 76
59 22
45 70
73 98
24 94
70 54
76 ...

output:

18.38477631085023844548
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
141.42135623730951010657
1...

result:

ok 200000 numbers

Test #8:

score: 0
Accepted
time: 305ms
memory: 26080kb

input:

200000 10000
8596 2507
1107 4452
8591 3460
3584 2911
8817 9663
1604 2760
6281 8431
5271 4811
2193 1874
5329 3970
2679 8672
8426 8447
117 4849
3471 6286
177 4806
9726 7217
6743 3882
573 4295
5291 7358
1356 6269
7882 8426
8750 985
5365 8276
7420 6372
8234 6329
7723 9014
3369 1097
7140 8329
3475 447
37...

output:

5530.98924244117552007083
13392.60243567321049340535
14142.13562373095192015171
14142.13562373095192015171
14142.13562373095192015171
14142.13562373095192015171
14142.13562373095192015171
14142.13562373095192015171
14142.13562373095192015171
14142.13562373095192015171
14142.13562373095192015171
1414...

result:

ok 200000 numbers

Test #9:

score: 0
Accepted
time: 391ms
memory: 39428kb

input:

200000 1000000000
979065421 937279323
384811311 879649222
673927841 883688174
47686221 518846247
805783947 475892423
94359891 104324315
116498230 496486640
155617000 261326127
423462080 949904263
758478482 824824842
594993542 173897699
495194886 158960628
409812195 339201236
958417812 891558399
7055...

output:

1355119095.86284399032592773438
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.3...

result:

ok 200000 numbers

Test #10:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

3 100
82 61
46 1
82 61

output:

111.72287142747451582636
111.72287142747451582636
2.82842712474619029095

result:

ok 3 numbers

Test #11:

score: 0
Accepted
time: 248ms
memory: 32896kb

input:

200000 200005
199999 1
199998 2
199997 3
199996 4
199995 5
199994 6
199993 7
199992 8
199991 9
199990 10
199989 11
199988 12
199987 13
199986 14
199985 15
199984 16
199983 17
199982 18
199981 19
199980 20
199979 21
199978 22
199977 23
199976 24
199975 25
199974 26
199973 27
199972 28
199971 29
19997...

output:

2.82842712474619029095
5.65685424949238058190
8.48528137423857131694
11.31370849898476116380
14.14213562373095101066
16.97056274847714263387
19.79898987322333070438
22.62741699796952232759
25.45584412271571395081
28.28427124746190202131
31.11269837220809364453
33.94112549695428526775
36.769552621700...

result:

ok 200000 numbers

Test #12:

score: 0
Accepted
time: 233ms
memory: 32380kb

input:

200000 200005
0 200000
1 199999
2 199998
3 199997
4 199996
5 199995
6 199994
7 199993
8 199992
9 199991
10 199990
11 199989
12 199988
13 199987
14 199986
15 199985
16 199984
17 199983
18 199982
19 199981
20 199980
21 199979
22 199978
23 199977
24 199976
25 199975
26 199974
27 199973
28 199972
29 199...

output:

282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840303421
282842.7124746190384...

result:

ok 200000 numbers

Test #13:

score: 0
Accepted
time: 305ms
memory: 32088kb

input:

200000 200005
188054 11946
25503 174497
5164 194836
199742 258
65650 134350
93448 106552
165510 34490
33001 166999
54081 145919
123066 76934
50244 149756
46561 153439
66523 133477
8593 191407
173633 26367
105494 94506
198495 1505
75564 124436
83182 116818
123337 76663
186899 13101
110487 89513
10858...

output:

33788.39043221798783633858
282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840303421
282842.71247461903840...

result:

ok 200000 numbers

Test #14:

score: 0
Accepted
time: 255ms
memory: 31892kb

input:

200000 200005
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
20 20
21 21
22 22
23 23
24 24
25 25
26 26
27 27
28 28
29 29
30 30
31 31
32 32
33 33
34 34
35 35
36 36
37 37
38 38
39 39
40 40
41 41
42 42
43 43
44 44
45 45
46 46
47 47
48 48
49 49
50 50
51 5...

output:

2.82842712474619029095
5.65685424949238058190
8.48528137423857131694
11.31370849898476116380
14.14213562373095101066
16.97056274847714263387
19.79898987322333070438
22.62741699796952232759
25.45584412271571395081
28.28427124746190202131
31.11269837220809364453
33.94112549695428526775
36.769552621700...

result:

ok 200000 numbers

Test #15:

score: 0
Accepted
time: 237ms
memory: 32304kb

input:

200000 200005
200000 200000
199999 199999
199998 199998
199997 199997
199996 199996
199995 199995
199994 199994
199993 199993
199992 199992
199991 199991
199990 199990
199989 199989
199988 199988
199987 199987
199986 199986
199985 199985
199984 199984
199983 199983
199982 199982
199981 199981
199980...

output:

282849.78354243090143427253
282849.78354243090143427253
282849.78354243090143427253
282849.78354243090143427253
282849.78354243090143427253
282849.78354243090143427253
282849.78354243090143427253
282849.78354243090143427253
282849.78354243090143427253
282849.78354243090143427253
282849.7835424309014...

result:

ok 200000 numbers

Test #16:

score: 0
Accepted
time: 314ms
memory: 31880kb

input:

200000 200005
99686 99686
193692 193692
142065 142065
56279 56279
120521 120521
147618 147618
148660 148660
1328 1328
69007 69007
5297 5297
136306 136306
136195 136195
101372 101372
66966 66966
110843 110843
170697 170697
23097 23097
146157 146157
118098 118098
11530 11530
42300 42300
74535 74535
17...

output:

281954.58635744871571660042
282849.78354243090143427253
282849.78354243090143427253
282849.78354243090143427253
282849.78354243090143427253
282849.78354243090143427253
282849.78354243090143427253
282849.78354243090143427253
282849.78354243090143427253
282849.78354243090143427253
282849.7835424309014...

result:

ok 200000 numbers

Test #17:

score: 0
Accepted
time: 119ms
memory: 14804kb

input:

200000 1000000000
227478108 704821317
227478108 704821317
227478108 704821317
227478108 704821317
227478108 704821317
227478108 704821317
227478108 704821317
227478108 704821317
227478108 704821317
227478108 704821317
227478108 704821317
227478108 704821317
227478108 704821317
227478108 704821317
22...

output:

1318470491.02763819694519042969
0.00000000000000000000
1318470491.02763819694519042969
0.00000000000000000000
1318470491.02763819694519042969
0.00000000000000000000
1318470491.02763819694519042969
0.00000000000000000000
1318470491.02763819694519042969
0.00000000000000000000
1318470491.02763819694519...

result:

ok 200000 numbers

Test #18:

score: 0
Accepted
time: 163ms
memory: 13844kb

input:

200000 1000000000
517510913 200230004
39507125 601409920
30526823 972694998
176712 534697072
789676092 648567171
967127462 822743807
176712 534697072
176712 534697072
117560602 867751869
967127462 822743807
227002346 310628813
789676092 648567171
800983841 618498638
39507125 601409920
517510913 2002...

output:

566335974.50163817405700683594
1015038939.09150195121765136719
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37...

result:

ok 200000 numbers

Test #19:

score: 0
Accepted
time: 193ms
memory: 15016kb

input:

200000 1000000000
351451808 649636951
49985291 500589827
661773922 164694264
186065541 226295124
497991267 744030929
574182692 439989249
853617452 979655888
308109763 216029731
66584658 40643821
855305206 820425533
740812379 441059394
151159173 495945962
214589103 777995590
957581330 407536966
88513...

output:

1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.37309503555297851562
1414213562.3...

result:

ok 200000 numbers

Test #20:

score: 0
Accepted
time: 139ms
memory: 15028kb

input:

200000 1000000000
821475126 617812186
464369722 134670005
821475126 617812186
464369722 134670005
464369722 134670005
821475126 617812186
464369722 134670005
464369722 134670005
464369722 134670005
464369722 134670005
821475126 617812186
464369722 134670005
464369722 134670005
464369722 134670005
46...

output:

1126190670.47231721878051757812
1126190670.47231721878051757812
380904295.03170508146286010742
0.00000000000000000000
380904295.03170508146286010742
1126190670.47231721878051757812
1126190670.47231721878051757812
1126190670.47231721878051757812
1126190670.47231721878051757812
1126190670.472317218780...

result:

ok 200000 numbers

Test #21:

score: 0
Accepted
time: 154ms
memory: 15692kb

input:

200000 11
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
8 1
10 10
3 1
1 2
9 10
1 4
5 1
1 5
1 6
7 7
2 1
4 1
5 3
7 9
6 4
3 7
6 1
1 8
2 5
2 9
10 9
6 10
9 8
1 2
7 3
6 6
6 6
7 5
1 9
7 9
3 5
9 5
3 3
6 8
10 9
7 5
5 1
2 1
3 2
5 5
8 1
4 9
9 8
1 3
4 8
8 9
2 10
1 4
7 3
4 1
1 2
1 2
5 1
5 4
1 3
2 1
6 2
6 8
5 9
10 7
5...

output:

2.82842712474619029095
4.24264068711928565847
5.65685424949238058190
7.07106781186547550533
8.48528137423857131694
9.89949493661166535219
11.31370849898476116380
12.72792206135785697541
14.14213562373095101066
15.55634918610404682227
15.55634918610404682227
15.55634918610404682227
15.556349186104046...

result:

ok 200000 numbers

Test #22:

score: 0
Accepted
time: 97ms
memory: 15168kb

input:

200000 4
1 1
2 1
3 1
1 1
3 2
3 3
2 1
3 3
2 1
2 2
2 2
3 1
2 2
3 3
1 2
2 3
1 2
2 1
2 2
1 2
3 1
2 2
2 1
2 1
3 3
2 2
1 2
1 3
2 1
3 3
2 3
3 1
2 1
1 2
1 3
3 1
2 3
2 1
1 2
3 3
1 3
3 3
2 3
2 3
2 1
3 1
3 3
1 2
2 1
2 1
1 1
1 3
1 1
1 1
2 3
2 2
1 2
1 1
1 3
1 1
1 2
1 1
2 3
1 1
2 2
2 2
2 1
2 1
3 2
1 1
3 1
1 2
1 1...

output:

2.82842712474619029095
4.24264068711928565847
5.65685424949238058190
4.24264068711928565847
4.24264068711928565847
5.65685424949238058190
5.65685424949238058190
4.24264068711928565847
4.24264068711928565847
5.65685424949238058190
4.24264068711928565847
4.24264068711928565847
5.65685424949238058190
5...

result:

ok 200000 numbers

Test #23:

score: 0
Accepted
time: 177ms
memory: 14544kb

input:

200000 51
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
11 1
12 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
40 1
41 1
42 1
43 1
44 1
45 1
46 1
47 1
48 1
49 1
50 1
2 47
25 41
44 8
35 38
37 24
42 32
40 48
19 4
26 4...

output:

2.82842712474619029095
4.24264068711928565847
5.65685424949238058190
7.07106781186547550533
8.48528137423857131694
9.89949493661166535219
11.31370849898476116380
12.72792206135785697541
14.14213562373095101066
15.55634918610404682227
16.97056274847714263387
18.38477631085023844548
19.798989873223330...

result:

ok 200000 numbers