Source Code
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, int> pll;

const ll INF = 1e18;
const ll INF2 = 1e15;

const int N = 100100;

struct Segment {
    ll value, offset;
    int i;

    Segment(ll value = INF, ll offset = INF, int i = -1) : value(value), offset(offset), i(i) {
    }

    bool operator<(const Segment& other) const {
        return value + offset < other.value + other.offset;
    }
};

struct SegmentTreeLazy {
#define Mid ((L + R) >> 1)
#define Left (Node << 1)
#define Right (Node << 1 | 1)

   private:
    const ll EL = INF;             /// identity element for lazy   /// Check this
    static const int Nax = 4 * N;  /// Check this

    int n;  /// Array length
    Segment Tree1[Nax];
    Segment Tree2[Nax];
    ll Lazy[Nax];

   public:
    SegmentTreeLazy(int n = 0) : n(n) {
        for (int Node = 0; Node < Nax; Node++) {
            Tree1[Node] = Segment();
            Tree2[Node] = Segment(0);
            Lazy[Node] = EL;
        }
    }

   private:
    Segment Unite(Segment x, Segment y) {  /// Check this
        return min(x, y);
    }

   private:
    void Merge(int Node) {
        Tree1[Node] = Unite(Tree1[Left], Tree1[Right]);
        Tree2[Node] = Unite(Tree2[Left], Tree2[Right]);
    }

   private:
    void PushLazy(int Node, int Len) {
        if (Lazy[Node] != EL) {
            if (Tree1[Node].value + Tree1[Node].offset > Lazy[Node] + Tree2[Node].offset) {
                Tree1[Node].value = Lazy[Node];
                Tree1[Node].offset = Tree2[Node].offset;
                Tree1[Node].i = Tree2[Node].i;
            }
            if (Len > 1) {
                Lazy[Left] = min(Lazy[Left], Lazy[Node]);    /// Check this
                Lazy[Right] = min(Lazy[Right], Lazy[Node]);  /// Check this
            }
            Lazy[Node] = EL;
        }
    }

   public:
    void Build(const vector<ll>& a) {
        Clear();
        n = a.size();
        Build(a, 1, 0, n - 1);
    }

   private:
    void Build(const vector<ll>& a, int Node, int L, int R) {
        Tree1[Node] = Segment();
        Tree2[Node] = Segment(0);
        Lazy[Node] = EL;
        if (L == R) {
            Tree1[Node] = Segment(INF, a[L], L);
            Tree2[Node] = Segment(0, a[L], L);
            return;
        }
        Build(a, Left, L, Mid);
        Build(a, Right, Mid + 1, R);
        Merge(Node);
    }

   public:
    void Update(int i, int j, ll x) {
        if (i < 0)
            i = 0;
        if (j >= n)
            j = n - 1;
        if (n <= 0 || i > j)
            return;
        Update(i, j, x, 1, 0, n - 1);
    }

   private:
    void Update(int i, int j, ll x, int Node, int L, int R) {
        PushLazy(Node, R - L + 1);
        if (j < L || R < i)
            return;
        if (i <= L && R <= j)
            return Lazy[Node] = x, PushLazy(Node, R - L + 1);
        Update(i, j, x, Left, L, Mid);
        Update(i, j, x, Right, Mid + 1, R);
        Merge(Node);
    }

   public:
    Segment Query(int i, int j) {
        if (i < 0)
            i = 0;
        if (j >= n)
            j = n - 1;
        if (n <= 0 || i > j)
            return Segment();
        return Query(i, j, 1, 0, n - 1);
    }

   private:
    Segment Query(int i, int j, int Node, int L, int R) {
        PushLazy(Node, R - L + 1);
        if (j < L || R < i)
            return Segment();
        if (i <= L && R <= j)
            return Tree1[Node];
        return Unite(Query(i, j, Left, L, Mid), Query(i, j, Right, Mid + 1, R));
    }

   public:
    void Destroy(int i) {
        if (i < 0 || i >= n) {
            return;
        }
        return Destroy(i, 1, 0, n - 1);
    }

   private:
    void Destroy(int i, int Node, int L, int R) {
        PushLazy(Node, R - L + 1);
        if (i < L || R < i) {
            return;
        }
        if (L == R) {
            return void(Tree1[Node].offset = Tree2[Node].offset = INF);
        }

        Destroy(i, Left, L, Mid);
        Destroy(i, Right, Mid + 1, R);
        Merge(Node);
    }

   private:
    void Clear() {
        for (int Node = 0; Node <= 4 * n; Node++)
            Tree1[Node] = Segment(), Tree2[Node] = Segment(0), Lazy[Node] = EL;
        n = 0;
    }

#undef Mid
#undef Left
#undef Right
};

SegmentTreeLazy myTree1;
SegmentTreeLazy myTree2;

int main() {
    int n, q;
    cin >> n >> q;

    vector<ll> a(n);
    for (ll& x : a) {
        scanf("%lld", &x);
    }

    vector<vector<int>> b(n), c(n);

    while (q--) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        x--, y--, z--;
        b[x].push_back(y);
        c[x].push_back(z);
    }

    myTree1.Build(a);
    myTree1.Update(0, 0, -a[0]);

    vector<ll> neg_a = a;
    for (ll& x : neg_a) {
        x = -x;
    }

    myTree2.Build(neg_a);
    myTree2.Update(0, 0, -neg_a[0]);

    vector<ll> answer(n, -1);

    while (true) {
        Segment s1 = myTree1.Query(0, n - 1);
        Segment s2 = myTree2.Query(0, n - 1);

        if (min(s1.value + s1.offset, s2.value + s2.offset) > INF2) {
            break;
        }

        int i = -1;

        if (s1 < s2) {
            i = s1.i;
            answer[i] = s1.value + s1.offset;
        } else {
            i = s2.i;
            answer[i] = s2.value + s2.offset;
        }

        for (int j = 0; j < b[i].size(); j++) {
            myTree1.Update(max(i + 1, b[i][j]), c[i][j], answer[i] - a[i]);
            myTree2.Update(b[i][j], min(i - 1, c[i][j]), answer[i] + a[i]);
        }

        myTree1.Destroy(i);
        myTree2.Destroy(i);
    }

    answer[0] = 0;
    for (int i = 0; i < n; i++) {
        printf("%lld%c", answer[i], " \n"[i + 1 == n]);
    }
}
Copy
Fallout: New Vegas Baraa_Armoush
GNU G++17
240 ms
59.1 MB
Accepted
Test Case #1
25 ms
44.3 MB
Accepted
Input
6 3
1 2 3 4 5 6
1 3 3
2 1 4
3 2 2
Output
0 3 2 5 -1 -1
Judge Output
0 3 2 5 -1 -1
Checker Message
6 numbers
Test Case #2
25 ms
44.4 MB
Accepted
Input
18 16
1 4 5 6 8 9 10 13 14 16 20 21 23 24 25 26 27 29
2 2 5
10 18 18
1 1 17
3 10 14
4 3 6
16 9 11
2 1 4
7 10 11
3 2 2
6 2 3
2 14 18
4 10 14
3 5 6
2 16 18
3 13 15
5 1 1
Output
0 3 4 5 7 8 9 12 13 15 19 20 22 23 24 25 26 28
Judge Output
0 3 4 5 7 8 9 12 13 15 19 20 22 23 24 25 26 28
Checker Message
18 numbers
Test Case #3
26 ms
44.3 MB
Accepted
Input
16 12
2 3 4 5 6 7 8 10 14 15 18 19 22 23 26 28
13 3 3
4 2 5
4 2 10
2 1 2
7 1 16
3 1 2
4 15 16
2 1 1
2 2 3
15 3 12
2 3 12
3 5 12
Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
Judge Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
Checker Message
16 numbers
Test Case #4
25 ms
44.4 MB
Accepted
Input
11 16
5 7 10 12 15 17 18 24 25 27 30
3 11 11
6 10 10
2 2 4
2 10 10
4 10 11
3 9 11
6 10 10
1 11 11
2 1 1
10 11 11
2 10 11
10 11 11
4 3 4
10 10 11
10 6 8
10 1 2
Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 25
Judge Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 25
Checker Message
11 numbers
Test Case #5
25 ms
44.6 MB
Accepted
Input
20 17
1 5 6 7 9 11 13 14 15 18 19 20 21 22 23 25 26 27 28 29
13 12 15
1 2 2
19 10 18
17 5 6
9 9 12
2 3 5
1 20 20
1 14 20
7 3 5
7 11 20
3 3 4
16 13 15
6 1 1
3 2 17
1 1 3
12 16 16
10 11 18
Output
0 4 5 6 8 10 12 13 14 17 18 19 20 21 22 24 25 26 27 28
Judge Output
0 4 5 6 8 10 12 13 14 17 18 19 20 21 22 24 25 26 27 28
Checker Message
20 numbers
Test Case #6
25 ms
44.5 MB
Accepted
Input
11 1
1 4 7 10 17 19 20 21 27 29 30
1 2 7
Output
0 3 6 9 16 18 19 -1 -1 -1 -1
Judge Output
0 3 6 9 16 18 19 -1 -1 -1 -1
Checker Message
11 numbers
Test Case #7
25 ms
44.5 MB
Accepted
Input
20 1
1 2 3 4 6 7 9 10 12 14 15 17 18 20 21 23 25 27 28 30
6 2 3
Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
Judge Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
Checker Message
20 numbers
Test Case #8
25 ms
44.5 MB
Accepted
Input
15 10
1 4 6 8 9 10 12 13 17 20 23 24 25 26 28
1 2 10
1 8 9
14 4 7
4 8 14
5 3 11
13 10 10
2 1 5
10 7 14
1 13 15
9 4 7
Output
0 3 5 7 8 9 11 12 16 19 22 23 24 25 27
Judge Output
0 3 5 7 8 9 11 12 16 19 22 23 24 25 27
Checker Message
15 numbers
Test Case #9
25 ms
44.5 MB
Accepted
Input
13 2
2 7 16 17 18 20 21 22 23 25 26 28 30
3 2 6
3 5 6
Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
Judge Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
Checker Message
13 numbers
Test Case #10
25 ms
44.5 MB
Accepted
Input
11 3
3 9 10 11 19 20 22 23 25 27 29
2 1 6
9 10 10
10 11 11
Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
Judge Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
Checker Message
11 numbers
Test Case #11
25 ms
44.5 MB
Accepted
Input
13 7
1 2 5 8 10 11 16 17 19 20 21 26 30
11 9 10
3 1 2
12 9 12
13 3 10
3 12 13
5 6 13
2 9 13
Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
Judge Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
Checker Message
13 numbers
Test Case #12
25 ms
44.5 MB
Accepted
Input
17 18
2 4 6 7 11 13 14 17 18 20 21 23 24 26 27 28 29
2 17 17
1 13 15
6 14 17
2 3 4
14 1 4
6 3 17
6 9 12
3 1 4
8 9 12
1 3 5
8 1 6
2 17 17
1 7 10
15 14 15
3 7 9
6 17 17
4 1 3
9 17 17
Output
0 6 4 5 9 19 12 15 16 18 19 21 22 24 25 34 27
Judge Output
0 6 4 5 9 19 12 15 16 18 19 21 22 24 25 34 27
Checker Message
17 numbers
Test Case #13
25 ms
44.5 MB
Accepted
Input
15 11
2 5 9 12 14 16 17 18 20 21 24 25 26 27 29
13 10 11
11 15 15
1 12 15
4 8 15
8 3 7
10 14 15
6 13 14
1 3 6
2 10 11
6 3 12
4 1 3
Output
0 17 7 10 12 14 15 16 18 19 22 23 24 25 27
Judge Output
0 17 7 10 12 14 15 16 18 19 22 23 24 25 27
Checker Message
15 numbers
Test Case #14
26 ms
44.5 MB
Accepted
Input
17 11
1 5 7 8 11 12 13 14 16 17 18 19 22 24 25 26 28
9 3 7
9 3 6
17 8 8
1 1 8
7 10 10
11 1 2
2 12 14
1 2 2
3 13 15
9 1 1
11 6 8
Output
0 4 6 7 10 11 12 13 -1 16 -1 18 21 23 24 -1 -1
Judge Output
0 4 6 7 10 11 12 13 -1 16 -1 18 21 23 24 -1 -1
Checker Message
17 numbers
Test Case #15
25 ms
44.5 MB
Accepted
Input
19 15
1 3 4 6 7 8 9 11 13 15 16 17 19 21 22 24 26 29 30
17 19 19
16 5 6
10 3 8
9 3 5
4 19 19
1 4 13
9 2 6
2 19 19
7 13 19
2 17 17
2 8 10
12 2 5
10 2 17
1 2 4
1 9 15
Output
0 2 3 5 6 7 8 10 12 14 15 16 18 20 21 23 25 28 29
Judge Output
0 2 3 5 6 7 8 10 12 14 15 16 18 20 21 23 25 28 29
Checker Message
19 numbers
Test Case #16
26 ms
44.5 MB
Accepted
Input
10 4
7 9 10 12 13 14 23 26 27 28
10 7 10
7 3 7
10 5 10
2 10 10
Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1
Judge Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1
Checker Message
10 numbers
Test Case #17
25 ms
44.5 MB
Accepted
Input
19 4
1 2 3 5 7 8 10 11 12 14 15 16 19 20 23 25 26 28 29
14 9 12
10 18 19
5 11 13
5 3 3
Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
Judge Output
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
Checker Message
19 numbers
Test Case #18
152 ms
54.0 MB
Accepted
Input
98541 41896
16771 19006 23637 48145 54648 65184 66253 91601 100234 100859 125549 127360 127982 130235 138747 147541 172514 176365 191139 191275 202424 204408 206228 219185 243120 243621 247168 248289 268325 270717 284528 287258 291075 293440 319312 ...
Output
0 2235 6866 31374 37877 48413 49482 74830 83463 84088 108778 110589 111211 113464 121976 130770 155743 159594 174368 174504 185653 187637 189457 202414 226349 226850 230397 231518 251554 253946 267757 270487 274304 276669 302541 314208 315985 335781...
Judge Output
0 2235 6866 31374 37877 48413 49482 74830 83463 84088 108778 110589 111211 113464 121976 130770 155743 159594 174368 174504 185653 187637 189457 202414 226349 226850 230397 231518 251554 253946 267757 270487 274304 276669 302541 314208 315985 335781...
Checker Message
98541 numbers
Test Case #19
240 ms
55.1 MB
Accepted
Input
96124 99252
4691 8105 32520 33158 36274 47409 59980 62970 73488 108449 128632 142187 152157 159748 177801 181601 183706 200777 221709 226166 229616 249350 266676 276103 279404 304541 315229 325796 336921 339466 350570 356475 358116 380130 399828 403...
Output
0 3414 27829 28467 31583 42718 55289 58279 68797 103758 123941 137496 147466 155057 173110 176910 179015 196086 217018 221475 224925 244659 261985 271412 274713 299850 310538 321105 332230 334775 345879 351784 353425 375439 395137 398443 410989 4202...
Judge Output
0 3414 27829 28467 31583 42718 55289 58279 68797 103758 123941 137496 147466 155057 173110 176910 179015 196086 217018 221475 224925 244659 261985 271412 274713 299850 310538 321105 332230 334775 345879 351784 353425 375439 395137 398443 410989 4202...
Checker Message
96124 numbers
Test Case #20
107 ms
49.8 MB
Accepted
Input
45135 48096
870 30217 30535 43389 43419 75226 103245 111524 120266 151181 163779 232754 290102 297127 299749 308959 325241 330108 331566 339204 352108 393705 416198 444340 458300 460988 461487 497659 502711 502941 517242 580952 597761 633896 668011 ...
Output
0 55691 55373 42519 42549 74356 102375 110654 119396 150311 162909 231884 289232 296257 298879 308089 324371 329238 330696 338334 351238 392835 415328 443470 457430 460118 460617 496789 501841 502071 516372 580082 596891 633026 667141 683087 694508 ...
Judge Output
0 55691 55373 42519 42549 74356 102375 110654 119396 150311 162909 231884 289232 296257 298879 308089 324371 329238 330696 338334 351238 392835 415328 443470 457430 460118 460617 496789 501841 502071 516372 580082 596891 633026 667141 683087 694508 ...
Checker Message
45135 numbers
Test Case #21
122 ms
50.1 MB
Accepted
Input
42718 64237
16955 22170 26281 50280 52794 115296 120718 128358 150539 157390 187101 192053 229181 235168 250566 261349 300684 318447 354291 369011 370642 379493 441105 467995 480333 481088 482491 488593 619532 624776 705937 734392 815909 816143 8350...
Output
0 5215 9326 33325 35839 98341 103763 111403 133584 140435 170146 175098 212226 218213 233611 244394 283729 301492 337336 352056 353687 362538 424150 451040 463378 464133 465536 471638 602577 607821 688982 717437 798954 799188 818134 872772 876160 89...
Judge Output
0 5215 9326 33325 35839 98341 103763 111403 133584 140435 170146 175098 212226 218213 233611 244394 283729 301492 337336 352056 353687 362538 424150 451040 463378 464133 465536 471638 602577 607821 688982 717437 798954 799188 818134 872772 876160 89...
Checker Message
42718 numbers
Test Case #22
103 ms
51.3 MB
Accepted
Input
76016 13081
5383 31053 33433 36664 43556 58350 62210 70370 92211 105973 149422 155629 161935 169173 169661 182536 206646 215939 226609 247234 270398 287075 292032 317426 331950 352796 367164 376636 381037 413362 427479 456922 457754 524754 538005 55...
Output
0 25274008 21171986 21168755 21161863 21147069 21143209 21135049 21113208 21099446 21055997 21049790 21043484 21036246 21035758 21022883 20998773 20989480 20978810 20958185 20935021 20918344 20913387 20887993 20873469 20852623 361781 371253 375654 4...
Judge Output
0 25274008 21171986 21168755 21161863 21147069 21143209 21135049 21113208 21099446 21055997 21049790 21043484 21036246 21035758 21022883 20998773 20989480 20978810 20958185 20935021 20918344 20913387 20887993 20873469 20852623 361781 371253 375654 4...
Checker Message
76016 numbers
Test Case #23
119 ms
51.7 MB
Accepted
Input
73599 29221
4333 9380 15286 15767 24335 49202 50841 77418 95313 95722 105659 111152 144002 170733 170771 234359 234392 268942 279503 288956 311568 326357 362622 370436 378159 393006 403653 415094 438800 457127 486661 494909 495166 497392 521380 5635...
Output
0 5047 10953 11434 20002 44869 46508 73085 90980 91389 101326 106819 139669 166400 166438 230026 230059 264609 275170 284623 307235 322024 358289 366103 373826 388673 399320 410761 434467 452794 482328 490576 490833 493059 517047 559198 562894 5727....
Judge Output
0 5047 10953 11434 20002 44869 46508 73085 90980 91389 101326 106819 139669 166400 166438 230026 230059 264609 275170 284623 307235 322024 358289 366103 373826 388673 399320 410761 434467 452794 482328 490576 490833 493059 517047 559198 562894 5727...
Checker Message
73599 numbers
Test Case #24
104 ms
51.9 MB
Accepted
Input
82611 10770
17687 22203 24613 25936 43335 62186 169492 176782 179219 181335 201592 209557 212180 215223 225883 258417 264386 308038 330530 333258 352597 358020 361782 364047 385283 400068 404933 465663 469308 472720 595018 620025 620215 631360 6652...
Output
0 4516 6926 8249 25648 44499 151805 159095 161532 163648 183905 191870 194493 197536 208196 240730 246699 290351 312843 315571 334910 340333 344095 346360 367596 382381 387246 447976 451621 455033 577331 602338 602528 613673 647563 649059 664905 670...
Judge Output
0 4516 6926 8249 25648 44499 151805 159095 161532 163648 183905 191870 194493 197536 208196 240730 246699 290351 312843 315571 334910 340333 344095 346360 367596 382381 387246 447976 451621 455033 577331 602338 602528 613673 647563 649059 664905 670...
Checker Message
82611 numbers
Test Case #25
130 ms
52.5 MB
Accepted
Input
80194 35422
7913 19512 39940 64911 83463 95987 111917 112634 136207 141766 143946 147486 171790 217924 220217 237962 241274 245712 253051 267933 268717 282207 283781 297399 316077 317979 355304 377314 378398 390262 390569 397824 406381 416825 423804...
Output
0 164549 144121 119150 100598 88074 104004 104721 128294 133853 136033 139573 163877 210011 212304 230049 233361 237799 245138 260020 260804 274294 275868 289486 308164 310066 347391 369401 370485 382349 382656 389911 398468 408912 415891 421196 427...
Judge Output
0 164549 144121 119150 100598 88074 104004 104721 128294 133853 136033 139573 163877 210011 212304 230049 233361 237799 245138 260020 260804 274294 275868 289486 308164 310066 347391 369401 370485 382349 382656 389911 398468 408912 415891 421196 427...
Checker Message
80194 numbers
Test Case #26
147 ms
52.6 MB
Accepted
Input
77777 51563
42862 44864 53905 70005 74993 88856 103769 113131 130881 165184 189008 192053 195428 201095 256375 268150 273130 277796 314923 319217 333976 363751 373463 397924 415856 418460 439233 440552 444276 455427 496676 499616 504608 509129 5173...
Output
0 2002 11043 27143 32131 45994 60907 70269 88019 122322 146146 149191 152566 158233 213513 225288 230268 234934 272061 276355 291114 320889 330601 355062 372994 375598 396371 397690 401414 412565 453814 456754 461746 466267 474488 510630 518908 5318...
Judge Output
0 2002 11043 27143 32131 45994 60907 70269 88019 122322 146146 149191 152566 158233 213513 225288 230268 234934 272061 276355 291114 320889 330601 355062 372994 375598 396371 397690 401414 412565 453814 456754 461746 466267 474488 510630 518908 5318...
Checker Message
77777 numbers
Test Case #27
63 ms
48.9 MB
Accepted
Input
51074 407
42366 116134 206207 225174 239983 268226 313326 336138 340660 347983 352542 369824 374028 385634 407562 419848 426250 428849 432269 469882 504407 504562 510688 541462 544113 558610 567444 571386 595908 608560 613452 623908 636020 649245 70...
Output
0 -1 -1 -1 1212629645 1212601402 1212556302 1212533490 1212528968 1212521645 1212517086 1212499804 96040568 96028962 96007034 95994748 95988346 95985747 95982327 95944714 95910189 95910034 95903908 95873134 95870483 95855986 95847152 95843210 958186...
Judge Output
0 -1 -1 -1 1212629645 1212601402 1212556302 1212533490 1212528968 1212521645 1212517086 1212499804 96040568 96028962 96007034 95994748 95988346 95985747 95982327 95944714 95910189 95910034 95903908 95873134 95870483 95855986 95847152 95843210 958186...
Checker Message
51074 numbers
Test Case #28
186 ms
53.2 MB
Accepted
Input
72734 96518
2082 12961 28845 29972 51810 54346 55490 76065 124281 127624 128319 137646 151896 161153 161672 218108 218331 226439 236062 246012 274203 281075 285002 291186 293384 306451 309405 325727 349178 386867 389186 393840 418324 422429 430048 4...
Output
0 10879 26763 27890 49728 52264 53408 73983 122199 125542 126237 135564 149814 159071 159590 216026 216249 224357 233980 243930 272121 278993 282920 289104 291302 304369 307323 323645 347096 384785 387104 391758 416242 420347 427966 428716 469740 51...
Judge Output
0 10879 26763 27890 49728 52264 53408 73983 122199 125542 126237 135564 149814 159071 159590 216026 216249 224357 233980 243930 272121 278993 282920 289104 291302 304369 307323 323645 347096 384785 387104 391758 416242 420347 427966 428716 469740 51...
Checker Message
72734 numbers
Test Case #29
103 ms
51.2 MB
Accepted
Input
70317 21171
16251 27010 47390 65563 70461 77139 77545 88071 106103 116057 117473 145987 148931 172222 223028 234798 274823 278721 295909 316708 327789 341783 345577 347871 361577 375308 382946 387232 426687 430765 431139 435672 437340 464345 465349 ...
Output
0 16494347 16473967 16455794 16450896 16444218 16443812 16433286 16415254 16405300 16403884 16375370 16372426 16349135 16298329 16286559 16246534 16242636 16225448 16204649 16193568 325532 329326 331620 345326 359057 366695 370981 410436 414514 4148...
Judge Output
0 16494347 16473967 16455794 16450896 16444218 16443812 16433286 16415254 16405300 16403884 16375370 16372426 16349135 16298329 16286559 16246534 16242636 16225448 16204649 16193568 325532 329326 331620 345326 359057 366695 370981 410436 414514 4148...
Checker Message
70317 numbers
Test Case #30
97 ms
49.5 MB
Accepted
Input
43614 37311
4423 9988 40760 51729 60949 69947 73170 88482 131677 150566 153165 177731 246440 262952 281799 283642 299180 304763 305979 320536 354005 403304 419640 450566 476874 493020 493307 528479 533018 546301 593307 612173 617810 644923 667563 69...
Output
0 5565 36337 47306 56526 65524 68747 84059 127254 146143 148742 173308 242017 258529 277376 279219 294757 300340 301556 316113 349582 398881 415217 446143 472451 488597 488884 524056 528595 541878 588884 607750 613387 640500 663140 692200 735082 774...
Judge Output
0 5565 36337 47306 56526 65524 68747 84059 127254 146143 148742 173308 242017 258529 277376 279219 294757 300340 301556 316113 349582 398881 415217 446143 472451 488597 488884 524056 528595 541878 588884 607750 613387 640500 663140 692200 735082 774...
Checker Message
43614 numbers
Test Case #31
185 ms
53.3 MB
Accepted
Input
76912 86155
63659 71416 77721 105340 116699 128264 131731 150732 156829 157721 166678 174023 177174 188316 248752 257304 271631 275691 292786 299533 305109 332684 339516 340223 351897 356559 358731 364849 383494 384974 392035 416263 436743 470891 47...
Output
0 7757 14062 41681 53040 64605 68072 87073 93170 94062 103019 110364 113515 124657 185093 193645 207972 212032 229127 235874 241450 269025 275857 276564 288238 292900 295072 301190 319835 321315 328376 352604 373084 407232 407768 423056 430860 4460....
Judge Output
0 7757 14062 41681 53040 64605 68072 87073 93170 94062 103019 110364 113515 124657 185093 193645 207972 212032 229127 235874 241450 269025 275857 276564 288238 292900 295072 301190 319835 321315 328376 352604 373084 407232 407768 423056 430860 4460...
Checker Message
76912 numbers
Test Case #32
132 ms
50.8 MB
Accepted
Input
50209 67704
12086 17752 28931 68662 79320 103710 115581 123149 130863 132939 141618 153236 206109 212720 227538 236924 259383 283251 290254 312457 389421 469557 473082 486950 489606 536310 548463 554273 557882 562195 585069 606459 698121 705278 7102...
Output
0 5666 16845 56576 67234 91624 103495 111063 118777 120853 129532 141150 194023 200634 215452 224838 247297 271165 278168 300371 377335 457471 460996 474864 477520 524224 536377 542187 545796 550109 572983 594373 686035 693192 698133 701702 749652 7...
Judge Output
0 5666 16845 56576 67234 91624 103495 111063 118777 120853 129532 141150 194023 200634 215452 224838 247297 271165 278168 300371 377335 457471 460996 474864 477520 524224 536377 542187 545796 550109 572983 594373 686035 693192 698133 701702 749652 7...
Checker Message
50209 numbers
Test Case #33
162 ms
50.8 MB
Accepted
Input
47792 83844
2813 21959 36415 75997 101697 113944 116001 126203 130395 133939 143654 167951 188799 222538 272361 276234 278960 280860 306363 308023 315061 364109 428648 433964 442572 510229 517890 530440 541412 552700 562143 567005 663116 676257 6829...
Output
0 19146 33602 73184 98884 111131 113188 123390 127582 131126 140841 165138 185986 219725 269548 273421 276147 278047 303550 305210 312248 361296 425835 431151 439759 507416 515077 527627 538599 549887 559330 564192 660303 673444 680119 685622 704088...
Judge Output
0 19146 33602 73184 98884 111131 113188 123390 127582 131126 140841 165138 185986 219725 269548 273421 276147 278047 303550 305210 312248 361296 425835 431151 439759 507416 515077 527627 538599 549887 559330 564192 660303 673444 680119 685622 704088...
Checker Message
47792 numbers
Test Case #34
160 ms
59.1 MB
Accepted
Input
100000 100000
999900001 999900002 999900003 999900004 999900005 999900006 999900007 999900008 999900009 999900010 999900011 999900012 999900013 999900014 999900015 999900016 999900017 999900018 999900019 999900020 999900021 999900022 999900023 99990...
Output
0 199997 399990 599979 799964 999945 1199922 1399895 1599864 1799829 1999790 2199747 2399700 2599649 2799594 2999535 3199472 3399405 3599334 3799259 3999180 4199097 4399010 4598919 4798824 4998725 5198622 5398515 5598404 5798289 5998170 6198047 6397...
Judge Output
0 199997 399990 599979 799964 999945 1199922 1399895 1599864 1799829 1999790 2199747 2399700 2599649 2799594 2999535 3199472 3399405 3599334 3799259 3999180 4199097 4399010 4598919 4798824 4998725 5198622 5398515 5598404 5798289 5998170 6198047 6397...
Checker Message
100000 numbers
Test Case #35
63 ms
46.6 MB
Accepted
Input
5000 100000
66253 127982 206228 437596 474688 897083 1179081 1366360 1747057 1933796 2015299 2088136 2459538 2722396 2730496 2885198 2999419 3459193 3459838 3542747 3836417 3991500 4021782 4201283 4317645 4467251 4658281 4728177 4853452 4889747 5077...
Output
0 1999682497 3999174841 5998156463 5998056965 5997593580 5622176810 5621989531 5621608834 4122178699 4122097196 4122024359 4121652957 4121390099 4121381999 4121227297 4121113076 4120653302 4120652657 4120569748 4120276078 4120120995 4120090713 41199...
Judge Output
0 1999682497 3999174841 5998156463 5998056965 5997593580 5622176810 5621989531 5621608834 4122178699 4122097196 4122024359 4121652957 4121390099 4121381999 4121227297 4121113076 4120653302 4120652657 4120569748 4120276078 4120120995 4120090713 41199...
Checker Message
5000 numbers
Test Case #36
61 ms
46.6 MB
Accepted
Input
5000 100000
59980 315229 478333 493128 538962 632047 801418 1070735 1378276 1482867 1595502 1642960 1896617 1954330 2087506 2137708 2223325 2393334 2544190 3034708 3043496 3171926 3513668 3639257 3747462 3960857 3987274 4291002 4383901 4476801 44801...
Output
0 1999355287 176783727 176768932 176723098 176630013 45611752 45342435 45034894 44930303 44817668 175619100 175365443 175307730 175174554 175124352 175038735 174868726 174717870 174227352 174218564 174090134 173748392 173622803 173514598 173301203 1...
Judge Output
0 1999355287 176783727 176768932 176723098 176630013 45611752 45342435 45034894 44930303 44817668 175619100 175365443 175307730 175174554 175124352 175038735 174868726 174717870 174227352 174218564 174090134 173748392 173622803 173514598 173301203 1...
Checker Message
5000 numbers
Test Case #37
61 ms
46.5 MB
Accepted
Input
5000 100000
339204 497659 738895 953957 1456414 1484632 2659342 2864102 3243366 3273484 3280250 3743054 4100169 4106098 4306535 4463930 4718842 4824019 5236165 5342974 5917775 5950685 6056668 6207278 6297661 6457598 6460056 6621265 6648020 6682743 6...
Output
0 793545619 221043675 220828613 233920454 233892236 232717526 232512766 232133502 232103384 232096618 232633190 232990305 232996234 233196671 233354066 233608978 233714155 234126301 234233110 234807911 234840821 234946804 235097414 235187797 2353477...
Judge Output
0 793545619 221043675 220828613 233920454 233892236 232717526 232512766 232133502 232103384 232096618 232633190 232990305 232996234 233196671 233354066 233608978 233714155 234126301 234233110 234807911 234840821 234946804 235097414 235187797 2353477...
Checker Message
5000 numbers
Test Case #38
63 ms
46.6 MB
Accepted
Input
5000 100000
261349 441105 482491 984051 1138433 1297471 2113757 2140576 2184515 2227580 2886596 2945859 3047571 3084791 3600461 3609259 3783385 3979550 3994718 4090721 4593248 5117619 5467438 6015317 6661708 6825736 6853510 6863007 7119631 7277521 7...
Output
0 1998405228 3601021482 3600519922 3600365540 3600206502 3599390216 3599363397 3599319458 3599276393 3598617377 3598558114 3598456402 3598419182 3597903512 3597894714 3597720588 3597524423 3597509255 3597413252 3596910725 3596386354 3596036535 35954...
Judge Output
0 1998405228 3601021482 3600519922 3600365540 3600206502 3599390216 3599363397 3599319458 3599276393 3598617377 3598558114 3598456402 3598419182 3597903512 3597894714 3597720588 3597524423 3597509255 3597413252 3596910725 3596386354 3596036535 35954...
Checker Message
5000 numbers
Test Case #39
62 ms
46.5 MB
Accepted
Input
5000 100000
182536 703772 1207988 1515002 1572506 1595283 2432134 2605159 2656786 3304440 3499393 3640372 3715928 3763868 3847437 3996564 4046957 4169070 4208030 4248549 4678363 4721199 4876887 4890698 5034359 5044089 5336997 5741206 5850954 6073182...
Output
0 1997488094 3993896478 3994203492 3994260996 3994283773 3995120624 3995293649 3995345276 3995992930 3996187883 3996328862 3996404418 3996452358 3996535927 3996685054 3996735447 3996857560 3996896520 3996937039 3997366853 3997409689 3997565377 39975...
Judge Output
0 1997488094 3993896478 3994203492 3994260996 3994283773 3995120624 3995293649 3995345276 3995992930 3996187883 3996328862 3996404418 3996452358 3996535927 3996685054 3996735447 3996857560 3996896520 3996937039 3997366853 3997409689 3997565377 39975...
Checker Message
5000 numbers