QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#358055#3276. 出题高手Froranzen100 ✓868ms38564kbC++148.7kb2024-03-19 16:47:512024-03-19 16:47:52

Judging History

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

  • [2024-03-19 16:47:52]
  • 评测
  • 测评结果:100
  • 用时:868ms
  • 内存:38564kb
  • [2024-03-19 16:47:51]
  • 提交

answer


#include <bits/stdc++.h>
#define rep(i, f, t) for(int i(f); i <= t; ++i)
#define re(i, t) for(int i(1); i <= t; ++i)
#define per(i, t, f) for(int i(t); i >= f; --i)
#define pe(i, t) for(int i(t); i >= 1; --i)
#define ste(i, f, t, s) for(int i(f); i <= t; i += s)
#define ets(i, t, f, s) for(int i(t); i >= f; i -= s)
#define each(i, x) for(auto &i : (x))
#define nx(i, u) for(int i(head[u]); i; i = e[i].nxt) 
typedef long long ll;
typedef long double lb;
typedef unsigned long long ull;
// #define int long long
using namespace std;
// typedef pair <double, int> pdi;
typedef pair <int, int> pii;
// typedef pair <string, bool> psb;
#define pb push_back
#define fi first
#define se second 
#define ix(l, r) ((l + r) | (l != r))
#define ls (ix(l, mid))
#define rs (ix(mid + 1, r))
#define mp(i, j) (make_pair(i, j))
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define i128 __int128
#define exp 1e-7
#define look_memory cerr<<abs(&sT-&eD)/1024.0/1024<<'\n'
int sT;    
 
struct IO {
    #define MAXSIZE 1<<21
    #define isdigit(x) (x >= '0' && x <= '9')
    #define isspace(x) (x == ' ' || x == '\n' || x == '\r' || x == '\t')
    char ibuf[MAXSIZE], obuf[MAXSIZE], *s1, *s2, *s3, endl, blank;
    int round[10] = {0, 0, 0, 0, 0, 1, 1, 1, 1}, sta[65], precisions;
    bool fail;
    FILE *in_stream, *out_stream;
    IO(FILE *_stream = stdin, FILE *__stream = stdout) { reset(_stream,__stream); }
    #if DEBUG
    #else
        ~IO() {close();}
    #endif
    inline void reset (FILE *_stream = stdin, FILE *__stream = stdout, bool reset = true) {
        s1 = s3 = ibuf, s2 = obuf, in_stream = _stream, out_stream = __stream, fail = false;
        if(reset) { endl = '\n'; blank = ' '; precisions = 6; }
    }
    inline void flush_in() {s3 = (s1 = ibuf) + fread(ibuf, 1, MAXSIZE, in_stream); }
    inline void flush_out() { fwrite(obuf, 1, s2-obuf, out_stream), s2 = obuf; }
    inline void flush_out_with_stream() { flush_out(); fflush(out_stream); } 
    inline char get() {
        #if DEBUG  
            return getchar();
        #endif
        return s1 == s3 && (flush_in(), fail = s1 == s3) ? 0 : *s1++;
    }
    inline void put(char ch) {
        #if DEBUG
            putchar(ch);
        #else
            s2-obuf == MAXSIZE ? flush_out(), 0 : 0, *s2++=ch;
        #endif
    }
    template <class T>
    inline void read(T &x) {
        bool sign = false; char c = get(); x = 0;
        while(!isdigit(c) && c) {sign=c=='-'; c = get(); }
        while(isdigit(c)) { x = (x<<1) + (x<<3) + (c^'0'); c = get(); }
        sign ? x = ~x+1 : 0;
    }
    inline void read(double &x) {
        bool sign = false; char c = get(); x = 0;
        while(!isdigit(c) && c) { sign=c=='-'; c = get(); }
        while(isdigit(c)) { x = x * 10 + (c^'0'); c = get(); }
        if(c=='.') { c = get(); double tmp = 1; while(isdigit(c)) { tmp /= 10, x += tmp * (c^'0'); c = get(); } }
        sign ? x = -x : 0;
    }
    inline void read(long double &x) {
        bool sign = false; register char c = get(); x = 0;
        while(!isdigit(c) && c) { sign=c=='-'; c = get(); }
        while(isdigit(c)) { x = x * 10 + (c^'0'); c = get(); }
        if(c == '.') { c = get(); register long double tmp = 1; while(isdigit(c)) { tmp /= 10, x += tmp * (c^'0'); c = get(); } }
        sign ? x = -x : 0;
    }
    inline void read(char *s) {
        char c = get();
        while(isspace(c)) c = get();
        while(!isspace(c) && c) { *s++=c; c = get(); }
        *s = '\0';
    }
    inline void read(char &c) {
        do
            c = get();
        while(isspace(c));
    }
    template <class T, class ...Args>
    inline void read(T &x, Args &...args) { read(x), read(args...); }
    template <class T>
    inline void write(T x) {
        int top = 0;
        if(x<0) { put('-'); sta[top++] = ~(x%10)+1, x /= 10; x = ~x+1; }
        else sta[top++] = x%10, x /= 10;
        while(x) sta[top++] = x%10 ,x /= 10;
        while(top) put(sta[--top]^'0');
    }
    inline void write(double y) {
        int top = 0;
        if(y<0) { put('-'); y=-y; }
        int x = y; y -=x;
        write(x);
        if(y) {
            do
                sta[top++] = y*10, y = y*10 - sta[top-1];
            while(top<precisions-1);
            sta[top++] = y*10 + round[(int)((y*10-((int)(y*10)))*10)];
        }
        put('.');
        for(int i(0); i<top; ++i) put(sta[i]^'0');
        for(int i(top); i<precisions; ++i) put('0');
    }
    inline void write(long double y) {
        register int top = 0;
        if(y<0) { put('-'); y=-y; }
        int x = y; y -= x;
        write(x);
        if(y) {
            do
                sta[top++] = y*10, y = y*10 - sta[top-1];
            while(top<precisions-1);
            sta[top++] = y*10 + round[(int)((y*10-((int)(y*10)))*10)];
        }
        put('.');
        for(register int i(0); i < top; ++i) put(sta[i]^'0');
        for(register int i(top); i < precisions; ++i) put('0');
    }
    inline void write(const char ch) { put(ch); }
    inline void write(char *s) { while(*s!='\0') put(*s++); }
    inline void write(const char *s) { while(*s!='\0') put(*s++); }
    inline void write(const std::string str) { write(str.c_str()); }
    inline IO &precision(const int x) { precisions=x; return *this; }
    template <class T,class ...Args>
    inline void write(T x,Args ...args) { write(x), blank?put(blank), 0:0, write(args...); }
    template <class ...Args>
    inline void writeln(Args ...args) { write(args...), endl?put(endl), 0:0; }
    template <class T>
    inline IO &operator>>(T &x) { read(x); return *this; }
    inline IO &operator>>(IO &x) { return *this; }
    template <class T>
    inline IO &operator<<(const T x) { write(x); return *this; }
    inline IO &operator<<(IO &x) { return *this; }
    inline operator bool() { return !fail; }
    template <class T>
    inline operator T() { T x; read(x); return x; }
    inline void open(FILE *_stream=stdin,FILE *__stream=stdout) { close(), reset(_stream, __stream, false); }
    inline void close() { flush_out_with_stream(); fclose(in_stream), fclose(out_stream); }
    #define read(x) io>>x
    #define out(x) io<<x
}io;
const int N = 5e5 + 5;
int n, a[N];
int m;
struct Que {
    int id, l, r;
}p[N];

bool cmp (Que a, Que b) {
    return a.r < b.r; 
}

int f[N];
ll ans[N][2], pre[N], tag[N][2], val[N][2];
int sq, bl[N], lth[N], rth[N];

void check (ll a, ll b, ll &x, ll &y) {
    if((i128)1 * a * y >= (i128)1 * b * x) {
        x = a, y = b;
    }
}

void update (int p, ll a, ll b) { 
    check(a, b, tag[bl[p]][0], tag[bl[p]][1]);
    check(a, b, val[p][0], val[p][1]);
}

void query (int id, int l, int r) {
    if(bl[l] + 1 >= bl[r]) {
        rep(i, l, r) check(val[i][0], val[i][1], ans[id][0], ans[id][1]);
        return ;
    }
    rep(i, l, rth[bl[l]]) check(val[i][0], val[i][1], ans[id][0], ans[id][1]);
    rep(i, lth[bl[r]], r) check(val[i][0], val[i][1], ans[id][0], ans[id][1]);
    rep(i, bl[l] + 1, bl[r] - 1) check(tag[i][0], tag[i][1], ans[id][0], ans[id][1]);
}

mt19937 rnd(time(0));

int main () {
    io >> n;
    sq = sqrt(n);
    re(i, n) bl[i] = (i - 1) / sq + 1;
    re(i, bl[n]) {
        lth[i] = rth[i-1] + 1;
        rth[i] = i * sq;
    }
    re(i, n) val[i][0] = tag[i][0] = 0, tag[i][1] = val[i][1] = 1;
    rth[bl[n]] = n;  
    re(r, n) { 
        io >> a[r];
        pre[r] = pre[r-1] + a[r];
        f[r] = r;
        int sum = 0;
        if(a[r] == 0) continue;
        if(a[r] < 0) {
            pe(l, r) {
                sum += a[l];
                if(sum >= 0) break;
                f[r] = l;
            } 
        }
        else {
            pe(l, r) {
                sum += a[l];
                if(sum <= 0) break;
                f[r] = l;
            }
        } 
    }
    io >> m; 
    re(i, m) {
        ans[i][0] = 0, ans[i][1] = 1; 
        io >> p[i].l >> p[i].r;
        p[i].id = i;
    } 
    if(m == 1) {
        re(i, n) {
            rep(j, i, min(n, i + 400)) {
                check(1ll * (pre[j] - pre[i-1]) * (pre[j] - pre[i-1]), j - i + 1, ans[1][0], ans[1][1]);
            }
        }

    }
    else {
        sort(p + 1, p + m + 1, cmp);
        int now = 1;
        re(i, n) {
            per(j, i, f[i]) update(j, 1ll * (pre[i] - pre[j-1]) * (pre[i] - pre[j-1]), i - j + 1);
            while(now <= m && p[now].r == i) {
                query(p[now].id, p[now].l, p[now].r);
                ++now;
            }
        }
    }
    re(i, m) {
        ll w = __gcd(ans[i][0], ans[i][1]);
        ans[i][0] /= w;
        ans[i][1] /= w;
        io << ans[i][0] << " " << ans[i][1] << "\n";
    }
    return 0;
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 24ms
memory: 28380kb

input:

2000
-113 314 -664 697 211 -199 -38 -190 8 -661 910 -811 -113 942 77 433 -261 -368 129 -525 968 -608 -21 38 -562 438 -935 -228 220 333 985 -430 916 586 764 476 794 664 383 503 206 -60 380 -130 -988 -904 -996 -304 -286 31 114 119 850 -942 714 -369 -842 250 -192 -462 -727 -427 -602 126 231 718 121 559...

output:

54826875 11
14638276 7
1185921 1
81018001 24
6310144 3
12545764 5
3362000 1
23068809 8
23068809 8
12545764 5
1444908 1
5424241 3
1083603 1
2140369 1
2752281 2
3095072 1
3003289 2
4959529 2
17106496 13
4780232 1
89605156 31
8543929 4
129163225 48
5094049 2
68591524 23
8543929 4
35688676 11
3775249 1
...

result:

ok 200000 numbers

Test #2:

score: 0
Accepted
time: 24ms
memory: 24844kb

input:

2000
717 273 112 -879 -487 -164 -403 -895 391 721 223 895 -34 146 -779 -84 253 44 690 716 975 -625 844 731 204 457 -790 349 -739 610 -536 -561 721 -868 -967 68 729 878 672 -158 -395 -836 383 -634 -371 -262 -443 -123 -20 354 198 171 681 -390 -964 954 735 713 -904 -900 -522 561 -639 -86 326 -479 448 -...

output:

82773604 23
58201641 20
2289169 1
40500496 19
1849372 1
12759184 5
2896804 1
14775048 7
7636232 5
1806005 1
3179089 2
26388769 16
1638050 1
2778889 2
156275001 49
17181522 7
2289169 1
6817321 3
758912 1
40500496 19
4941729 2
8276763 5
5841889 3
3250809 2
1806005 1
2289169 1
156275001 49
9684544 5
25...

result:

ok 200000 numbers

Test #3:

score: 0
Accepted
time: 24ms
memory: 26512kb

input:

2000
-851 -108 -432 344 -251 251 529 923 363 -346 416 -296 -686 832 565 66 150 -492 70 0 -977 -275 -454 -409 -979 353 -511 -458 -403 632 250 -689 -15 773 664 -386 931 -866 436 -213 711 -961 662 -849 -286 -143 -7 -933 960 -523 135 -609 86 408 643 -147 437 411 -580 -184 735 -968 417 977 863 325 518 83...

output:

15984004 5
2520500 1
49900050 19
28451556 13
12830724 5
2975625 2
24157225 11
1733522 1
11909401 4
15864289 5
8487200 3
1733522 1
1733522 1
6993800 3
15721225 6
1937664 1
3411409 2
11377129 5
2849344 3
1594323 1
15984004 5
15864289 5
7557001 6
2050624 1
2286387 1
1733522 1
49900050 19
5320322 3
3910...

result:

ok 200000 numbers

Test #4:

score: 0
Accepted
time: 21ms
memory: 28376kb

input:

2000
269 60 -850 537 -525 -153 877 649 998 -864 -642 -77 -69 -127 537 315 -521 -922 -629 277 162 -541 659 -572 -542 -203 -997 494 364 156 276 -780 -274 94 -410 -215 -700 -840 -906 352 972 -61 824 -973 841 80 -180 634 496 -111 934 -692 328 151 297 -13 -465 380 450 -324 -367 40 318 -447 -820 -340 -107...

output:

41190724 9
1872300 1
3530641 1
12061729 7
17032129 6
7873636 3
21641104 7
100876808 37
7946761 5
10246401 4
1836025 1
12061729 7
1836025 1
2490010 1
1687500 1
7946761 5
3613801 2
14768649 5
11404129 5
7873636 3
22033636 15
10246401 4
10067929 4
1453248 1
41190724 9
9006001 5
1718658 1
5428900 3
4452...

result:

ok 200000 numbers

Test #5:

score: 0
Accepted
time: 20ms
memory: 26964kb

input:

2000
599 530 -362 736 -402 -252 901 -481 318 -100 716 -726 221 -887 217 455 -516 -948 -10 -963 -373 42 -968 -949 -440 -643 -649 35 197 64 -141 -465 -975 -804 -735 -847 396 100 -131 219 543 571 -566 653 -308 725 105 668 -509 416 309 -945 260 -302 -704 -914 -648 495 -595 32 -831 -607 -104 373 -810 -12...

output:

1154640400 203
2812329 1
11826721 4
35224225 11
3276726 1
74528689 18
11539609 5
24433249 12
1431432 1
17884441 6
51739249 12
2339280 1
1565001 1
2354988 1
3276726 1
1920800 1
11539609 5
21846050 11
964324 1
11548332 5
5433561 4
142324900 29
31102929 17
35224225 11
1569992 1
8720209 4
8892324 5
6165...

result:

ok 200000 numbers

Subtask #2:

score: 15
Accepted

Test #6:

score: 15
Accepted
time: 137ms
memory: 27028kb

input:

100000
754 792 -680 426 425 347 481 -690 530 378 73 -907 -431 45 -530 -552 440 -890 -15 712 695 -679 -310 13 718 805 193 -291 -877 -74 -355 511 -679 -395 166 -710 -657 -19 874 26 832 507 854 -289 700 -404 472 -302 -977 8 -698 40 766 705 369 838 700 -964 552 -535 -75 -608 -181 -503 468 447 772 904 -2...

output:

466344025 67

result:

ok 2 number(s): "466344025 67"

Test #7:

score: 0
Accepted
time: 141ms
memory: 26460kb

input:

100000
-387 -313 -47 -714 -74 239 8 591 541 -633 -660 981 -230 -148 -813 -802 -108 -543 -640 50 962 137 -972 -936 -975 885 793 -541 932 861 -348 885 -280 -977 -677 964 355 604 54 -977 -548 979 -516 136 437 -697 -23 -748 492 897 -538 785 617 -840 675 -978 307 -288 -493 682 678 -623 613 762 -622 -283 ...

output:

2417885584 385

result:

ok 2 number(s): "2417885584 385"

Test #8:

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

input:

100000
-127 303 92 -235 -794 293 -272 199 -175 693 -799 -750 -501 -283 -358 -657 -867 -152 -399 -299 530 -5 285 959 390 -928 617 -478 -889 -133 -492 -855 986 -664 -984 -690 887 -738 39 -570 -268 -767 640 883 711 -748 -75 426 -268 -541 -926 -792 902 214 561 -428 -285 781 -225 -299 -233 134 -896 569 -...

output:

202236841 30

result:

ok 2 number(s): "202236841 30"

Test #9:

score: 0
Accepted
time: 142ms
memory: 28340kb

input:

100000
-340 -696 48 -515 -584 -60 -888 257 214 -889 782 915 905 -964 -536 459 779 -519 -338 -867 622 -902 655 -153 600 -117 269 -887 -242 -985 -267 132 406 98 -368 400 -871 -908 -489 118 -140 -755 -869 -943 965 609 47 -748 194 -160 994 527 871 119 -891 580 -687 865 826 56 -978 -775 -47 792 313 -944 ...

output:

272184004 39

result:

ok 2 number(s): "272184004 39"

Test #10:

score: 0
Accepted
time: 131ms
memory: 28960kb

input:

100000
-736 -691 738 209 -411 -136 792 -110 -441 -753 254 744 -958 -317 312 856 245 995 912 87 -830 131 393 37 -400 934 279 -784 -308 618 -647 967 527 -162 -874 -770 188 -917 -855 772 482 -373 -749 -40 80 -459 710 -354 221 -343 -132 -947 -445 62 -744 851 848 554 -530 -892 -721 -910 -642 -138 -480 -7...

output:

393070276 51

result:

ok 2 number(s): "393070276 51"

Subtask #3:

score: 30
Accepted

Test #11:

score: 30
Accepted
time: 779ms
memory: 38536kb

input:

500000
794 -75 -596 -322 -945 -908 -609 -164 488 626 -877 -710 140 -120 -475 -837 738 669 634 -643 -682 667 816 -785 -608 -836 -860 -932 242 70 -620 268 -121 288 209 -392 732 750 558 -480 565 327 -217 -891 767 211 -690 -66 813 -889 952 615 432 19 411 800 678 718 522 422 940 -510 -544 449 -357 640 40...

output:

1878442281 242

result:

ok 2 number(s): "1878442281 242"

Test #12:

score: 0
Accepted
time: 868ms
memory: 38528kb

input:

500000
145 33 695 -456 761 -556 698 272 121 -445 100 -93 954 485 161 798 -279 921 456 570 151 -880 456 -640 -69 385 -301 -707 -84 -514 -964 597 874 346 841 274 -727 -177 -44 -883 903 -792 -776 926 416 -862 -247 -985 518 674 174 535 -295 960 -952 722 -947 -365 366 -520 -60 -404 800 811 -139 779 735 3...

output:

457831609 56

result:

ok 2 number(s): "457831609 56"

Test #13:

score: 0
Accepted
time: 799ms
memory: 38536kb

input:

500000
762 -391 336 983 -962 920 -428 955 487 -525 281 514 851 -508 607 153 -439 -307 345 557 -615 -997 272 813 -556 -69 -401 -625 143 -142 -499 380 749 613 -190 173 -633 -489 -285 183 -799 645 -863 379 169 -177 993 -184 753 346 58 770 254 705 -467 -700 -337 587 -333 685 -1 -618 -961 327 -33 -722 65...

output:

1160015481 110

result:

ok 2 number(s): "1160015481 110"

Test #14:

score: 0
Accepted
time: 739ms
memory: 38564kb

input:

500000
-819 -236 -303 662 -316 -328 51 821 717 -423 -565 -394 858 -816 -246 -993 831 -999 237 779 52 -642 826 945 307 -675 83 -715 -797 -451 -250 996 53 -765 -869 -717 -126 -250 532 -848 82 -100 542 80 798 701 -648 -433 234 362 462 -770 554 -211 -368 -653 897 -940 416 632 734 -18 727 319 -328 697 11...

output:

188897536 23

result:

ok 2 number(s): "188897536 23"

Test #15:

score: 0
Accepted
time: 854ms
memory: 38536kb

input:

500000
-161 619 -969 31 102 781 561 617 -685 -814 385 -998 911 -206 -404 519 276 -318 -731 -908 901 856 839 333 124 481 29 407 -315 -219 896 956 -286 996 -991 -800 951 109 -846 624 750 -88 955 -752 -814 134 -316 -777 844 391 359 -324 789 -713 -620 849 -553 575 357 792 -735 -828 373 378 -213 -501 -29...

output:

167832025 17

result:

ok 2 number(s): "167832025 17"

Subtask #4:

score: 15
Accepted

Test #16:

score: 15
Accepted
time: 165ms
memory: 28536kb

input:

100000
-496 -233 354 -632 -196 177 -878 -255 -19 -636 685 -70 101 -975 -406 -988 -965 -205 563 -766 763 511 -116 -746 -129 14 106 928 -457 -257 -283 226 3 899 -359 -792 615 490 -57 986 -243 624 -239 931 -555 -821 -72 -611 -380 -397 248 -132 956 -195 -322 -231 319 -214 837 -379 -931 -301 -4 -673 280 ...

output:

1352474176 205
13957947 4
67914081 16
33243858 7
10885778 3
27836176 7
50680161 11
235284921 74
106770889 25
2411809 2
2835045 1
14017536 5
134699236 43
286523329 74
28100601 11
17546888 5
23396569 6
80839443 25
4012009 3
2661336 1
42947912 11
3474284 1
61496964 19
3672245 1
6120676 3
7573504 3
1489...

result:

ok 10000 numbers

Test #17:

score: 0
Accepted
time: 235ms
memory: 26508kb

input:

100000
-869 53 -81 127 179 138 -838 925 306 178 -55 -225 -567 534 949 -510 713 -280 -889 370 708 258 -726 -235 17 41 51 -405 -889 647 -308 997 -219 84 -271 662 -139 -492 979 -103 -624 732 606 -629 -40 242 231 -23 -332 524 -963 -991 366 790 691 902 536 476 -799 959 150 931 794 -601 794 942 598 148 11...

output:

84621601 13
58094884 11
119880601 30
101929216 29
146482609 33
214066161 52
223353025 54
491996761 112
12616704 5
1132096 1
6633507 2
45603009 14
89397025 26
665898025 103
61449921 19
5938947 2
13069100 3
44382244 11
9834496 5
3317760 1
18037009 6
35162498 11
4385829 1
27331984 7
48135844 13
6473883...

result:

ok 10000 numbers

Test #18:

score: 0
Accepted
time: 223ms
memory: 27104kb

input:

100000
-640 205 550 38 938 622 -23 525 -242 554 772 -491 -11 -567 -243 -59 -449 449 -691 805 -822 -486 111 -166 -379 994 645 704 197 -932 654 -349 382 60 -101 -872 -506 645 453 736 -699 965 -988 -149 758 891 -595 772 648 545 122 3 -239 523 -140 996 612 793 -883 932 809 -285 228 873 371 739 648 616 7...

output:

130553476 17
5112121 3
502681 1
210665405 39
739600 1
28504921 7
6956450 3
8898289 4
418609 1
765075600 109
2512225 1
21451250 7
21635042 5
45212176 11
312865344 49
3682561 2
380689 1
451584 1
3195392 1
1909620 1
1973163 1
35343025 8
11546404 7
82150562 25
80209936 23
82210489 15
1723969 2
141376 1
...

result:

ok 10000 numbers

Test #19:

score: 0
Accepted
time: 277ms
memory: 29080kb

input:

100000
762 -774 -441 -718 454 -111 -614 526 363 545 308 -159 572 -894 967 299 -866 -201 -553 -312 -634 365 265 25 308 -232 -380 -361 654 656 -522 -815 -18 955 -954 -854 111 879 -575 753 -996 885 -188 389 478 -11 -437 0 -546 289 -266 708 566 -932 -843 -38 -531 440 227 857 -697 -109 371 96 70 -271 -3 ...

output:

52654322 9
52654322 9
12180100 7
444830281 67
1944075 1
101124 1
20079361 5
39463524 11
51825601 20
1678112 1
23726641 6
5896178 3
6436369 3
15961250 3
354025 1
9006001 6
12082576 5
312936100 63
123187801 24
11135569 4
26122321 5
48986001 8
205434889 34
1860500 1
87781250 17
145226601 31
444830281 6...

result:

ok 10000 numbers

Test #20:

score: 0
Accepted
time: 206ms
memory: 29208kb

input:

100000
227 -437 -47 722 -894 -928 -542 859 -798 -393 -429 -319 -432 106 -732 -793 420 542 -313 -907 146 638 -169 618 873 -699 747 62 -977 983 275 194 -216 -511 647 960 1000 -712 -797 -299 53 458 -598 581 -251 770 965 214 382 135 21 547 747 -499 -564 -256 -517 635 788 -88 -919 302 201 -600 -588 47 -9...

output:

902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581...

result:

ok 10000 numbers

Test #21:

score: 0
Accepted
time: 364ms
memory: 29080kb

input:

100000
-389 -434 -758 -766 -641 -265 280 -682 623 228 -902 155 811 220 507 193 235 -915 432 -490 682 -941 -408 776 150 -691 239 -104 -728 430 -807 145 -700 224 -191 522 -839 -296 -266 885 -590 -189 705 49 456 -164 487 685 6 -919 -133 614 -311 -691 -388 47 -931 685 337 -935 386 902 -67 901 738 -562 7...

output:

6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
6146018 1
...

result:

ok 10000 numbers

Test #22:

score: 0
Accepted
time: 271ms
memory: 29228kb

input:

100000
131 387 494 -299 717 -866 200 944 -252 -202 -312 268 685 -816 -379 440 373 740 547 -731 -713 -810 -949 -80 124 -692 560 -270 -70 617 -911 -924 432 50 -736 -150 258 407 -387 960 108 684 -228 139 -975 -382 576 762 -359 629 -925 -548 134 517 -173 -21 -667 -490 -553 -313 -253 -127 836 227 636 425...

output:

318515409 41
91642329 13
91642329 13
318515409 41
318515409 41
318515409 41
318515409 41
318515409 41
91642329 13
91642329 13
91642329 13
91642329 13
91642329 13
318515409 41
91642329 13
91642329 13
318515409 41
91642329 13
91642329 13
318515409 41
91642329 13
91642329 13
91642329 13
318515409 41
91...

result:

ok 10000 numbers

Test #23:

score: 0
Accepted
time: 297ms
memory: 28936kb

input:

100000
-205 849 -540 641 -663 877 -418 -732 -236 701 611 -964 283 -841 619 -362 41 120 -982 -756 818 727 -237 249 940 786 139 46 666 -767 782 -749 -643 29 780 551 775 -307 508 133 334 120 639 570 886 845 -764 -162 -734 676 -84 -759 -751 775 -270 965 33 378 -14 -640 437 -381 -858 880 -673 816 561 -42...

output:

1266932836 159
10224242 3
4831204 3
17041122 5
2762244 1
63297936 19
12552849 4
14737921 8
102556129 45
6482116 3
243859456 55
2264645 1
27573001 7
2485125 1
65934400 19
149940025 46
5358132 1
22174681 8
1297321 2
149940025 46
15856324 5
711128889 160
41280625 12
238300969 94
436016161 85
72301009 1...

result:

ok 10000 numbers

Test #24:

score: 0
Accepted
time: 159ms
memory: 29072kb

input:

100000
-197 -705 945 -782 638 -962 -76 880 -6 -680 -167 382 -93 -277 -191 -483 487 510 632 708 576 -450 -650 -541 -95 -604 -684 371 361 793 -723 -902 -428 543 540 -94 873 -24 507 625 473 -15 743 -915 -353 -967 -277 -89 -637 -849 -649 -653 -718 268 -208 -741 311 -447 364 308 151 -5 999 49 942 665 707...

output:

1787175625 188
77880625 21
17673616 7
62583921 19
256032001 58
11363641 4
3055392 1
219099204 49
79727041 21
756900 1
3007584 1
18879025 6
67782289 16
181090849 32
26776562 7
35319249 8
50979600 11
14691889 5
915849 1
3271840 1
110040100 29
150381169 43
10738729 4
66129424 17
4743684 1
12020089 4
75...

result:

ok 10000 numbers

Test #25:

score: 0
Accepted
time: 171ms
memory: 27108kb

input:

100000
529 36 -532 594 -781 -718 -709 306 720 592 777 247 984 905 997 687 216 566 391 -665 552 -775 911 328 -655 -476 59 -616 -151 -928 434 472 57 16 -672 928 216 377 -999 982 -384 -642 -907 -14 392 -143 -178 671 444 -737 992 -922 23 -143 4 -994 820 87 946 -602 824 171 284 -232 -739 415 -44 578 685 ...

output:

130119649 20
60109009 13
21818241 7
8296707 2
2673225 1
324360100 91
9529569 4
144024001 34
125955729 25
154449 1
80528283 17
179021042 35
113443801 35
14684224 5
29041321 11
10413529 5
106998336 29
113443801 35
1395372 1
24720784 9
26368225 8
3099593 1
113443801 35
2484300 1
3441025 2
51236964 17
8...

result:

ok 10000 numbers

Test #26:

score: 0
Accepted
time: 310ms
memory: 28640kb

input:

100000
-493 -894 -731 700 983 816 -165 -749 -973 121 -873 157 -537 -651 748 219 -4 -837 -246 -26 793 -524 -883 408 -244 266 317 -923 930 -512 -411 -688 999 -854 4 830 348 -664 594 -320 -579 405 -307 -873 953 -589 -963 -677 518 252 472 -696 728 396 -645 -764 633 -467 -717 882 -904 180 408 -390 -821 7...

output:

32959081 5
47316992 9
40589641 8
173791489 35
40589641 8
178907528 31
47316992 9
19921783 3
178907528 31
32959081 5
178907528 31
262893796 43
201696804 31
32959081 5
262893796 43
40589641 8
32959081 5
147015625 24
147015625 24
173791489 35
32959081 5
147015625 24
262893796 43
51652969 9
32959081 5
3...

result:

ok 10000 numbers

Test #27:

score: 0
Accepted
time: 212ms
memory: 29076kb

input:

100000
-640 205 550 38 938 622 -23 525 -242 554 772 -491 -11 -567 -243 -59 -449 449 -691 805 -822 -486 111 -166 -379 994 645 704 197 -932 654 -349 382 60 -101 -872 -506 645 453 736 -699 965 -988 -149 758 891 -595 772 648 545 122 3 -239 523 -140 996 612 793 -883 932 809 -285 228 873 371 739 648 616 7...

output:

4867015696 677
130553476 17
130553476 17
765075600 109
130553476 17
4867015696 677
374074281 64
765075600 109
765075600 109
765075600 109
765075600 109
374074281 64
82210489 15
46648900 9
130553476 17
4867015696 677
46648900 9
193493792 33
124746561 26
130553476 17
130553476 17
82210489 15
46648900 ...

result:

ok 10000 numbers

Test #28:

score: 0
Accepted
time: 277ms
memory: 28716kb

input:

100000
762 -774 -441 -718 454 -111 -614 526 363 545 308 -159 572 -894 967 299 -866 -201 -553 -312 -634 365 265 25 308 -232 -380 -361 654 656 -522 -815 -18 955 -954 -854 111 879 -575 753 -996 885 -188 389 478 -11 -437 0 -546 289 -266 708 566 -932 -843 -38 -531 440 227 857 -697 -109 371 96 70 -271 -3 ...

output:

15961250 3
330257929 63
6040683 1
15961250 3
48986001 8
15961250 3
330257929 63
1136903524 191
444830281 67
87086224 15
1136903524 191
1136903524 191
48986001 8
1136903524 191
48986001 8
48986001 8
1136903524 191
444830281 67
444830281 67
15961250 3
444830281 67
48986001 8
87086224 15
87086224 15
11...

result:

ok 10000 numbers

Test #29:

score: 0
Accepted
time: 180ms
memory: 27036kb

input:

100000
-159 -507 -198 -446 -359 -943 -550 -229 -575 455 -691 361 -197 -634 986 -502 -908 -719 234 -832 509 -422 233 558 339 -981 758 474 -641 172 -731 -227 13 35 615 249 -679 611 525 990 949 277 -365 -470 81 -536 884 94 -366 780 -449 832 -170 -528 -518 -143 -622 78 -44 161 -12 111 962 -391 -212 755 ...

output:

14142037 2
9053712801 1588
9053712801 1588
127464100 17
9053712801 1588
42081138 7
42081138 7
127464100 17
14142037 2
42081138 7
9053712801 1588
42081138 7
127464100 17
14142037 2
127464100 17
429276961 71
127464100 17
42081138 7
14142037 2
127464100 17
429276961 71
127464100 17
42081138 7
14142037 ...

result:

ok 10000 numbers

Test #30:

score: 0
Accepted
time: 216ms
memory: 29156kb

input:

100000
-768 -991 514 -297 -458 376 -260 53 -527 220 -517 -969 90 -303 -163 25 -922 696 149 -971 155 -167 -683 987 527 -95 40 -829 -328 533 631 349 147 666 76 550 -703 15 955 -7 15 -256 -176 259 759 322 913 -460 -344 -507 469 -581 -723 785 -471 -589 -480 161 664 -605 -637 -821 -837 211 153 -597 -998 ...

output:

129937201 19
129937201 19
188705169 31
72437121 14
72437121 14
5225796 1
730729024 129
4941729 1
4941729 1
72437121 14
11703241 2
129937201 19
11703241 2
5225796 1
4941729 1
72437121 14
129937201 19
306985441 55
11703241 2
72437121 14
306985441 55
25718792 5
5225796 1
11703241 2
730729024 129
125507...

result:

ok 10000 numbers

Subtask #5:

score: 35
Accepted

Test #31:

score: 35
Accepted
time: 349ms
memory: 37552kb

input:

100000
139 -485 -497 -818 254 169 -560 22 377 -67 -243 -75 743 -788 -676 -26 -775 371 576 -303 54 733 422 800 445 687 479 -16 -288 259 783 -586 912 616 439 -416 676 -555 172 659 501 -868 337 22 -60 260 603 -982 -149 466 769 -595 -117 949 -544 904 753 20 776 175 -888 937 -792 -647 -615 59 -298 452 -6...

output:

401594700 47
3916125 1
4343056 1
23049601 8
19713600 7
62900761 15
46076944 15
6620329 2
3775805 1
7868025 4
20659592 7
66569281 16
3354050 1
48818169 10
10629610 3
44129449 10
62837329 19
10975969 2
2958400 1
6786025 2
2683044 1
3323047 1
83631025 17
10329796 3
78198649 18
7840000 3
401594700 47
65...

result:

ok 600000 numbers

Test #32:

score: 0
Accepted
time: 378ms
memory: 35240kb

input:

100000
244 483 10 493 887 79 730 759 -244 -687 -602 -782 -741 80 -546 556 -11 563 231 -917 664 917 861 -265 -682 -869 -134 616 -20 703 27 163 -804 -671 854 -495 365 110 257 -462 310 151 648 -983 -716 50 953 202 320 750 -439 -611 763 -813 -545 357 108 -872 -782 816 163 613 -712 -873 -595 -754 897 100...

output:

1795301641 246
48762289 16
99380961 25
82283041 19
3441025 1
87516025 21
100217645 19
64770304 19
26460736 9
21874329 11
3656448 1
16016004 5
263900025 71
130669778 35
4118023 1
16032016 5
19331762 5
591024721 179
144 1
73736569 22
13307904 5
6185169 2
24334489 8
320123664 85
1178342929 274
51051025...

result:

ok 600000 numbers

Test #33:

score: 0
Accepted
time: 344ms
memory: 38292kb

input:

100000
-570 556 -165 38 441 403 98 294 -267 -94 466 -186 -131 457 399 910 -770 -921 -987 -150 -997 810 398 -769 484 667 -674 -604 -115 -28 770 -640 269 641 358 -801 -91 943 -817 1000 583 359 870 -725 709 -372 337 -365 -661 45 540 956 48 83 -284 -8 -912 -628 -65 711 -460 215 -423 88 -352 326 132 15 2...

output:

1251362 1
5595040 1
34904464 13
70757408 11
10883401 6
59327427 13
70757408 11
40666129 10
67081 2
829921 1
974169 1
466489 1
70757408 11
5595040 1
13209800 3
368449 1
5595040 1
80425024 17
13388281 4
219869584 45
19044 1
835396 1
219869584 45
4176050 1
19819808 7
4255443 1
3142300 1
5595040 1
70757...

result:

ok 600000 numbers

Test #34:

score: 0
Accepted
time: 359ms
memory: 37492kb

input:

100000
848 449 -207 557 -703 -178 -48 -59 -981 675 497 323 806 -968 -714 -993 -518 -231 -288 259 297 954 857 803 640 466 560 -800 644 750 406 -476 -841 -11 938 -17 418 -371 550 -300 -204 560 -922 -223 -462 -566 672 -914 -718 165 433 -522 429 -327 -420 -962 427 -589 893 121 852 -379 745 -719 252 -178...

output:

14641 1
3442688 1
1569992 1
60326289 16
222337921 42
2461761 1
50140098 13
138675 1
6456681 4
1315609 1
2033919801 392
1949400 1
15864289 8
29849575 6
1434818 1
2666689 1
17438763 7
6076225 3
34456900 7
35664784 13
1605289 1
1279227 1
186624 1
1087849 2
19562929 8
2615606449 479
140398801 33
1329409...

result:

ok 600000 numbers

Test #35:

score: 0
Accepted
time: 428ms
memory: 37636kb

input:

100000
404 785 250 -668 126 -666 -773 -123 -791 811 629 249 411 -290 -931 774 244 655 293 -383 -376 -664 479 -222 -636 -343 558 770 590 119 -549 -648 421 913 364 731 -961 -97 704 598 -590 -197 -89 821 -206 261 230 164 583 -523 483 -373 -245 120 999 547 732 576 -475 -936 696 -183 -541 972 943 -531 82...

output:

144408289 25
4187579 1
151757761 45
2488416 1
129345129 31
3348900 1
264030001 51
10764800 3
13549761 4
10923025 4
4044168 1
31259281 7
24157225 6
31259281 7
4583881 2
26101881 7
6165289 3
3348900 1
1645298 1
35366809 10
35081929 10
4044168 1
2691325 1
21669025 6
243422404 61
23929362 7
95082001 27
...

result:

ok 600000 numbers

Test #36:

score: 0
Accepted
time: 465ms
memory: 38276kb

input:

100000
-649 -165 411 98 975 -155 -607 28 79 -125 -272 -101 379 -870 225 522 230 139 -587 -620 -970 703 399 239 -53 -633 -337 884 -783 638 330 5 -166 -267 -784 -136 115 -955 -881 523 448 110 -382 -43 -151 -896 776 -565 -814 -16 -139 -928 -559 -791 -93 78 892 -688 161 332 666 -32 -237 -353 -226 -631 -...

output:

194769936 31
104509729 26
22963264 7
15367968 5
29408929 8
7479723 2
5494972 1
21274707 4
21859272 5
7480225 4
38473992 11
49501250 11
19492225 8
4099683 1
17496675 4
173738761 36
126468608 31
544008976 143
2246760 1
97851664 25
49210225 13
32417352 7
17522596 5
26440992 7
4388293 1
133795489 46
794...

result:

ok 600000 numbers

Test #37:

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

input:

100000
-807 -835 -742 -534 -138 776 -898 -430 791 -874 -723 595 594 -949 -183 -919 -685 946 427 674 -111 -353 945 -964 41 -932 196 -322 -31 -451 -951 931 -329 -834 -120 -503 -541 471 -665 -979 -422 -428 -396 -72 -193 -932 702 -3 -972 -807 -864 429 -140 -736 823 253 -833 -23 -659 -445 -111 -654 238 -...

output:

65419224 7
23961025 6
14776336 5
26081449 9
8752928 3
17783089 5
9339842 3
23406244 9
91107025 26
28291761 8
208484721 71
42237001 11
5736025 2
9759362 3
2332445 1
21780889 6
18619225 8
35093776 11
1517282 1
2540258 1
13010449 5
2076672 1
18258529 5
25371369 8
11498881 4
13068225 4
9339842 3
1820232...

result:

ok 600000 numbers

Test #38:

score: 0
Accepted
time: 363ms
memory: 36912kb

input:

100000
711 -257 220 653 -615 943 372 -215 581 -853 423 497 -115 -330 335 432 532 90 -858 -13 -951 210 -598 681 -726 -559 -24 331 771 -546 137 -996 -756 308 280 992 949 54 390 716 9 221 -947 17 -308 261 564 159 -204 92 287 603 586 171 -791 734 98 -907 852 -721 642 -250 -483 -117 -308 -443 56 -707 562...

output:

80730225 14
787727432 125
12680721 2
12680721 2
80730225 14
6090865936 1065
6090865936 1065
54879845 9
1657141264 243
24814128 5
1657141264 243
12680721 2
1657141264 243
86918329 16
24814128 5
12680721 2
1657141264 243
22364672 5
1657141264 243
54879845 9
24814128 5
1056344648 199
12680721 2
1657141...

result:

ok 600000 numbers

Test #39:

score: 0
Accepted
time: 388ms
memory: 37476kb

input:

100000
-833 422 656 24 175 278 -768 -865 295 648 -552 -960 887 -319 -98 -701 870 837 140 -734 -399 -803 67 760 487 -514 -34 994 692 866 981 -71 -637 216 358 148 -350 914 -17 -618 -525 823 -371 626 -986 338 -306 -726 730 -839 744 712 -517 -76 577 -456 112 766 275 -994 -120 -189 -227 -970 323 -981 -77...

output:

201441249 31
10439361 2
201441249 31
201441249 31
25694761 4
182628196 25
127080529 23
72982849 14
201441249 31
201441249 31
182628196 25
10439361 2
182628196 25
592046224 93
25694761 4
182628196 25
39945603 7
201441249 31
25694761 4
174715524 31
201441249 31
182628196 25
127080529 23
182628196 25
1...

result:

ok 600000 numbers

Test #40:

score: 0
Accepted
time: 387ms
memory: 38416kb

input:

100000
-617 -817 810 -124 -633 399 -405 1000 858 657 -510 -582 -165 -269 -267 478 -766 262 -166 -253 433 354 -40 216 -331 -830 -854 667 949 817 431 155 778 -959 -112 -581 -571 999 -581 -992 556 987 849 -389 248 -600 -681 850 -405 -656 840 -662 838 -814 673 587 38 116 -691 820 -480 -506 -471 132 910 ...

output:

106151809 17
188183524 29
106151809 17
106151809 17
188183524 29
27028575 4
135465800 23
188183524 29
938503225 118
106151809 17
106151809 17
143688169 27
106151809 17
106151809 17
27028575 4
106151809 17
106151809 17
106151809 17
113720896 19
106151809 17
27028575 4
938503225 118
27028575 4
1436881...

result:

ok 600000 numbers

Test #41:

score: 0
Accepted
time: 396ms
memory: 37436kb

input:

100000
-570 556 -165 38 441 403 98 294 -267 -94 466 -186 -131 457 399 910 -770 -921 -987 -150 -997 810 398 -769 484 667 -674 -604 -115 -28 770 -640 269 641 358 -801 -91 943 -817 1000 583 359 870 -725 709 -372 337 -365 -661 45 540 956 48 83 -284 -8 -912 -628 -65 711 -460 215 -423 88 -352 326 132 15 2...

output:

239878144 41
557809924 101
169702729 30
557809924 101
557809924 101
239878144 41
70757408 11
239878144 41
792309904 121
239878144 41
792309904 121
377758096 69
557809924 101
557809924 101
66275881 12
187197124 35
169702729 30
187197124 35
557809924 101
169702729 30
96118416 17
125507209 22
5595040 1...

result:

ok 600000 numbers

Test #42:

score: 0
Accepted
time: 401ms
memory: 37440kb

input:

100000
848 449 -207 557 -703 -178 -48 -59 -981 675 497 323 806 -968 -714 -993 -518 -231 -288 259 297 954 857 803 640 466 560 -800 644 750 406 -476 -841 -11 938 -17 418 -371 550 -300 -204 560 -922 -223 -462 -566 672 -914 -718 165 433 -522 429 -327 -420 -962 427 -589 893 121 852 -379 745 -719 252 -178...

output:

228191236 27
552955225 101
2615606449 479
17112500 3
228191236 27
76790169 13
228191236 27
145998889 30
2615606449 479
552955225 101
228191236 27
39652209 8
76790169 13
2615606449 479
1127280625 209
145998889 30
2615606449 479
145998889 30
228191236 27
39652209 8
228191236 27
228191236 27
76790169 1...

result:

ok 600000 numbers