QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#69827#1392. Cukierki [C]mik10 ✓899ms3712kbC++14671b2023-01-02 03:44:272023-01-02 03:44:29

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-02 03:44:29]
  • 评测
  • 测评结果:10
  • 用时:899ms
  • 内存:3712kb
  • [2023-01-02 03:44:27]
  • 提交

answer

#include <cstdio>
#include <set>
#include <map>

#define M 1000000007

int main ()
{
  std::multiset <int> m;
  int n;
  scanf ("%i", &n);
  while (n--)
  {
    int a;
    scanf ("%i", &a);
    m.emplace (a);
  }
  int x = std::max (1, m.empty ()? 1: *m.rbegin ()-1);
  std::map <int, int> t;
  for (auto i=m.begin(); i!=m.end(); ++i)
  {
    for (auto j=t.end(); j!=t.begin();)
    {
      --j;
      if (j->first < *i-1) break;
      (t[std::min (j->first + *i, x)] += j->second) %= M;
    }
    if (*i == 1) ++t[1];
  }
  int c = 0;
  for (auto j=t.begin(); j!=t.end(); ++j) (c += j->second) %= M;
  printf ("%i\n", c);
  return 0;
}

詳細信息

Subtask #1:

score: 1
Accepted

Test #2:

score: 1
Accepted
time: 3ms
memory: 3020kb

input:

9
3 1 4 9 1 7 15 11 7

output:

33

result:

ok single line: '33'

Test #3:

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

input:

1
1

output:

1

result:

ok single line: '1'

Test #4:

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

input:

3
1 1 2

output:

6

result:

ok single line: '6'

Test #5:

score: 0
Accepted
time: 2ms
memory: 3084kb

input:

5
5 1 2 1 2

output:

17

result:

ok single line: '17'

Test #6:

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

input:

7
9 16 16 1 3 1 3

output:

10

result:

ok single line: '10'

Test #7:

score: 0
Accepted
time: 2ms
memory: 3096kb

input:

9
4 2 15 1 6 11 6 8 8

output:

61

result:

ok single line: '61'

Test #8:

score: 0
Accepted
time: 2ms
memory: 3084kb

input:

9
1 1 2 3 2 2 2 1 2

output:

445

result:

ok single line: '445'

Test #9:

score: 0
Accepted
time: 2ms
memory: 3096kb

input:

9
1 4 1 3 1 1 2 2 1

output:

471

result:

ok single line: '471'

Test #10:

score: 0
Accepted
time: 2ms
memory: 2976kb

input:

9
1 2 1 1 1 4 1 1 1

output:

480

result:

ok single line: '480'

Test #11:

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

input:

9
1 1 1 1 1 1 1 1 1

output:

511

result:

ok single line: '511'

Test #12:

score: 0
Accepted
time: 2ms
memory: 3048kb

input:

9
7 4 6 9 2 5 1 8 3

output:

94

result:

ok single line: '94'

Subtask #2:

score: 1
Accepted

Test #13:

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

input:

9
13 20 13 19 18 4 3 18 13

output:

0

result:

ok single line: '0'

Test #14:

score: 0
Accepted
time: 2ms
memory: 2968kb

input:

2
2 1

output:

2

result:

ok single line: '2'

Test #15:

score: 0
Accepted
time: 2ms
memory: 3088kb

input:

4
1 1 2 1

output:

14

result:

ok single line: '14'

Test #16:

score: 0
Accepted
time: 2ms
memory: 3124kb

input:

6
2 1 1 1 2 1

output:

60

result:

ok single line: '60'

Test #17:

score: 0
Accepted
time: 2ms
memory: 3092kb

input:

8
13 3 10 4 11 6 1 1

output:

24

result:

ok single line: '24'

Test #18:

score: 0
Accepted
time: 2ms
memory: 3096kb

input:

9
1 1 1 2 1 5 1 1 1

output:

438

result:

ok single line: '438'

Test #19:

score: 0
Accepted
time: 2ms
memory: 3248kb

input:

9
1 2 1 2 12 1 1 3 2

output:

250

result:

ok single line: '250'

Test #20:

score: 0
Accepted
time: 2ms
memory: 3032kb

input:

9
2 5 2 9 1 1 1 4 1

output:

325

result:

ok single line: '325'

Test #21:

score: 0
Accepted
time: 2ms
memory: 2976kb

input:

9
16 20 8 1 4 20 20 2 20

output:

20

result:

ok single line: '20'

Test #22:

score: 0
Accepted
time: 2ms
memory: 3084kb

input:

9
20 20 20 20 20 20 20 20 20

output:

0

result:

ok single line: '0'

Subtask #3:

score: 1
Accepted

Test #23:

score: 1
Accepted
time: 1ms
memory: 3024kb

input:

20
4419 1890 3362 2822 4346 753 4622 3681 3224 2596 2791 4665 137 4876 1949 2584 3962 3388 4341 1791

output:

0

result:

ok single line: '0'

Test #24:

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

input:

20
510 17 11 137 1 11 2 3 2 19 1 72 4 30 1 2 46 1 128 92

output:

60919

result:

ok single line: '60919'

Test #25:

score: 0
Accepted
time: 2ms
memory: 3060kb

input:

18
2 2 36 356 47 54 306 7 4 1 209 7 486 3 48 134 18 8

output:

3787

result:

ok single line: '3787'

Test #26:

score: 0
Accepted
time: 2ms
memory: 3124kb

input:

20
16 1 8 21 235 3 32 410 1 16 101 1 5 4 1253 35 8 1021 1 548

output:

6022

result:

ok single line: '6022'

Test #27:

score: 0
Accepted
time: 2ms
memory: 3048kb

input:

18
13 13 44 1 1 3 1 1 1 1 23 6 1 3 3 7 4 8

output:

157985

result:

ok single line: '157985'

Test #28:

score: 0
Accepted
time: 2ms
memory: 3032kb

input:

19
1 2 1 1 3 2 1 14 1 1 19 1 6 1 2 3 5 28 1

output:

311241

result:

ok single line: '311241'

Test #29:

score: 0
Accepted
time: 2ms
memory: 3120kb

input:

19
3 2 1 1 4 8 1 15 2 1 2 1 3 22 3 12 1 1 2

output:

415154

result:

ok single line: '415154'

Test #30:

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

input:

20
5000 5000 32 5000 1024 5000 256 4096 4 512 16 5000 64 128 2 2048 5000 8 5000 1

output:

140

result:

ok single line: '140'

Test #31:

score: 0
Accepted
time: 3ms
memory: 3020kb

input:

20
5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000

output:

0

result:

ok single line: '0'

Subtask #4:

score: 1
Accepted

Test #32:

score: 1
Accepted
time: 1ms
memory: 3104kb

input:

18
2302 4083 3312 1999 4884 517 4239 4086 1381 1844 414 1419 2544 4942 1293 2571 1744 2789

output:

0

result:

ok single line: '0'

Test #33:

score: 0
Accepted
time: 2ms
memory: 3112kb

input:

19
2 71 151 353 3 37 415 2 77 31 9 924 114 5 2 507 10 1 6

output:

2409

result:

ok single line: '2409'

Test #34:

score: 0
Accepted
time: 2ms
memory: 3072kb

input:

20
3 5 554 44 6 10 1 72 383 11 702 16 26 1 1205 2 20 1 95 135

output:

13860

result:

ok single line: '13860'

Test #35:

score: 0
Accepted
time: 2ms
memory: 3128kb

input:

18
4 23 1108 6 2 2 1 246 57 24 414 13 447 16 124 58 13 77

output:

2198

result:

ok single line: '2198'

Test #36:

score: 0
Accepted
time: 2ms
memory: 3108kb

input:

18
2 1 4 1 27 8 4 11 1 2 1 24 3 1 1 15 2 22

output:

153894

result:

ok single line: '153894'

Test #37:

score: 0
Accepted
time: 2ms
memory: 3084kb

input:

18
1 1 3 8 1 3 2 14 15 1 1 4 3 17 3 1 4 4

output:

212680

result:

ok single line: '212680'

Test #38:

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

input:

18
1 67 11 1 1 2 1 9 1 3 1 3 6 32 1 2 1 4

output:

83082

result:

ok single line: '83082'

Test #39:

score: 0
Accepted
time: 2ms
memory: 2972kb

input:

20
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

output:

1048575

result:

ok single line: '1048575'

Test #40:

score: 0
Accepted
time: 2ms
memory: 3016kb

input:

20
7 15 8 3 11 19 4 2 17 16 10 18 1 6 20 5 14 13 12 9

output:

183101

result:

ok single line: '183101'

Subtask #5:

score: 1
Accepted

Test #41:

score: 1
Accepted
time: 1ms
memory: 3100kb

input:

100
64 10 52 91 67 62 4 83 8 1 74 79 88 93 98 24 80 55 29 52 68 63 35 51 71 15 97 65 13 100 81 97 6 97 82 20 64 44 50 42 14 83 77 55 37 10 41 13 66 60 98 50 70 77 67 57 57 3 42 83 28 21 44 51 60 64 25 18 94 23 40 66 42 41 82 7 60 84 71 28 21 72 85 39 60 25 3 12 88 50 14 31 18 88 10 4 66 31 32 62

output:

1

result:

ok single line: '1'

Test #42:

score: 0
Accepted
time: 2ms
memory: 3100kb

input:

100
23 78 46 82 2 52 27 31 20 8 82 26 79 1 94 65 16 15 34 18 13 1 59 77 80 62 62 25 29 61 93 41 68 56 58 5 100 67 54 28 59 56 44 40 23 87 2 73 47 29 34 63 77 48 13 63 48 79 75 17 11 49 85 16 4 6 73 28 80 52 18 45 37 15 14 5 68 5 29 37 66 65 53 15 61 1 90 62 47 16 13 63 80 9 28 39 5 69 56 67

output:

444157038

result:

ok single line: '444157038'

Test #43:

score: 0
Accepted
time: 2ms
memory: 3068kb

input:

98
65 32 100 88 79 9 37 6 91 45 1 7 5 6 84 11 97 44 42 93 75 7 7 48 69 73 95 15 65 16 4 65 2 50 22 2 71 8 98 80 87 32 99 81 99 80 7 81 12 81 36 80 62 5 54 47 13 14 37 38 7 43 88 82 85 2 12 93 8 45 86 89 4 62 94 2 85 31 15 2 29 29 80 30 15 63 32 46 7 86 6 36 96 58 28 93 34 39

output:

363156298

result:

ok single line: '363156298'

Test #44:

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

input:

100
51 11 70 95 83 2 69 59 58 81 80 2 63 30 76 100 52 60 65 98 39 40 61 56 31 30 1 56 8 15 81 22 41 21 2 78 46 8 18 17 11 2 88 89 64 9 13 75 3 21 22 82 15 54 71 4 66 96 82 76 87 86 57 83 77 81 43 33 3 44 10 44 52 3 88 4 5 94 75 19 11 90 2 41 65 63 49 39 84 69 25 68 57 73 40 50 16 46 97 22

output:

898788844

result:

ok single line: '898788844'

Test #45:

score: 0
Accepted
time: 2ms
memory: 3104kb

input:

100
12 1 4 50 1 1 6 3 3 1 3 1 22 4 9 14 1 30 2 2 1 1 24 2 2 64 1 2 9 14 2 2 3 18 19 3 2 2 57 59 16 4 5 66 21 46 17 41 4 11 5 2 3 1 3 2 40 10 3 1 63 18 7 1 18 41 1 29 2 4 2 1 2 28 28 1 29 2 1 24 45 5 56 9 63 16 2 1 2 1 9 24 61 1 88 2 63 7 24 4

output:

435282500

result:

ok single line: '435282500'

Test #46:

score: 0
Accepted
time: 2ms
memory: 3132kb

input:

100
76 1 5 45 16 19 9 23 3 15 19 34 13 2 4 3 39 5 15 7 12 1 22 3 93 1 1 2 5 12 42 2 10 82 15 3 1 7 42 1 1 5 2 4 90 7 6 5 15 3 2 1 1 2 1 6 4 4 6 40 1 9 1 2 50 1 32 46 1 1 1 3 1 1 15 1 1 22 87 29 1 5 12 62 1 1 1 16 13 7 1 1 3 49 3 1 1 1 2 17

output:

569421096

result:

ok single line: '569421096'

Test #47:

score: 0
Accepted
time: 2ms
memory: 3116kb

input:

100
1 39 3 1 1 7 1 2 30 3 1 20 17 37 2 10 3 3 2 81 7 1 39 28 42 4 1 2 2 22 2 5 1 1 3 3 24 10 11 12 1 41 19 4 28 4 3 1 2 2 14 4 3 2 21 2 1 4 1 37 1 2 10 30 4 15 1 1 2 7 2 7 1 31 1 11 2 1 52 4 2 1 1 37 2 1 3 1 59 13 1 1 1 1 6 2 4 3 4 23

output:

356048725

result:

ok single line: '356048725'

Test #48:

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

input:

100
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 4 100 64 2 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 1 100 100 100 100 100 100 32 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 ...

output:

484190410

result:

ok single line: '484190410'

Subtask #6:

score: 1
Accepted

Test #49:

score: 1
Accepted
time: 2ms
memory: 3052kb

input:

100
36 74 42 89 99 42 95 49 52 44 45 22 36 83 42 13 51 17 31 78 65 94 67 21 76 31 58 38 67 29 30 49 13 40 73 61 93 9 95 34 66 54 13 7 95 58 48 58 6 63 24 38 37 15 66 73 76 36 74 13 15 30 36 78 71 56 54 61 40 91 73 51 46 44 76 73 99 50 41 12 74 55 84 75 84 50 97 5 28 91 20 61 42 61 38 35 64 15 12 20

output:

0

result:

ok single line: '0'

Test #50:

score: 0
Accepted
time: 3ms
memory: 3016kb

input:

99
83 83 22 31 77 74 53 9 7 53 17 27 63 2 70 20 36 44 50 55 26 9 22 23 46 88 12 27 84 4 11 2 81 71 32 97 22 89 33 3 60 50 15 80 14 19 41 25 54 11 4 67 21 41 41 4 57 91 80 67 69 21 86 24 79 62 89 1 5 35 12 69 51 14 82 16 67 68 4 49 20 96 6 55 14 57 80 3 4 1 68 2 93 55 74 8 74 34 25

output:

555312694

result:

ok single line: '555312694'

Test #51:

score: 0
Accepted
time: 2ms
memory: 3252kb

input:

100
7 32 21 75 76 95 36 4 35 74 79 62 77 12 52 72 70 33 77 86 51 73 6 1 12 13 50 17 27 36 71 40 35 38 4 6 100 84 80 41 3 15 11 1 18 17 4 12 45 2 94 41 57 31 40 28 41 84 83 41 1 18 23 99 73 29 86 19 16 19 6 48 63 10 96 55 66 50 52 66 10 1 92 13 77 44 2 27 6 13 9 29 20 93 41 94 45 71 37 65

output:

453562180

result:

ok single line: '453562180'

Test #52:

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

input:

100
27 7 17 28 56 49 25 15 64 2 52 5 13 1 55 24 55 34 11 36 87 61 1 69 5 2 78 1 47 11 76 80 80 36 49 53 7 58 31 95 57 44 47 25 70 86 37 49 51 44 18 93 16 31 8 95 38 46 47 8 49 50 38 12 47 2 48 2 24 79 39 99 43 72 17 72 36 1 75 81 70 17 19 37 62 4 51 14 15 95 30 82 29 56 93 88 44 96 5 10

output:

672168839

result:

ok single line: '672168839'

Test #53:

score: 0
Accepted
time: 2ms
memory: 2988kb

input:

97
2 4 61 7 1 2 16 19 2 3 15 1 46 1 1 4 9 11 32 4 2 2 1 11 2 30 1 2 5 12 1 1 12 4 15 54 48 6 5 17 4 31 2 1 4 1 2 5 29 4 3 1 2 27 1 2 84 1 3 2 27 1 3 42 1 7 4 1 8 3 79 8 6 2 3 1 15 1 12 1 3 2 1 1 29 4 2 1 4 1 6 1 2 98 14 8 1

output:

822123624

result:

ok single line: '822123624'

Test #54:

score: 0
Accepted
time: 3ms
memory: 2980kb

input:

95
33 1 2 1 6 2 3 1 2 2 1 1 1 44 16 1 11 1 1 1 3 4 3 22 2 28 1 1 10 88 5 52 3 5 1 4 2 29 1 40 16 3 3 1 1 2 1 1 2 26 10 1 42 56 2 8 5 1 63 88 1 4 94 13 2 8 1 1 1 1 1 1 20 1 68 52 3 6 7 5 2 14 4 1 1 1 17 2 21 1 4 1 4 11 6

output:

974289318

result:

ok single line: '974289318'

Test #55:

score: 0
Accepted
time: 2ms
memory: 3256kb

input:

100
1 7 4 10 1 2 1 10 94 99 16 15 3 1 3 1 4 54 1 1 1 26 1 20 1 1 1 4 1 25 2 7 7 11 15 3 11 10 3 1 69 5 85 30 1 32 1 16 4 47 3 1 3 2 3 4 3 1 29 47 7 2 20 20 2 70 2 61 1 9 1 1 1 2 21 10 1 40 64 2 2 1 1 1 49 1 1 1 1 17 3 3 2 4 48 54 1 3 5 28

output:

749895955

result:

ok single line: '749895955'

Test #56:

score: 0
Accepted
time: 2ms
memory: 3036kb

input:

100
23 15 1 24 56 39 85 84 97 38 13 73 8 91 70 14 22 93 30 64 20 34 95 29 66 31 89 57 63 10 51 21 96 71 53 32 75 55 72 17 47 25 68 99 33 88 44 35 41 79 6 2 11 98 58 16 50 7 49 36 27 90 69 65 48 26 86 77 45 67 74 100 78 4 37 87 46 9 81 82 18 59 76 5 94 12 92 60 62 43 42 54 61 83 28 80 3 52 40 19

output:

396296848

result:

ok single line: '396296848'

Subtask #7:

score: 1
Accepted

Test #57:

score: 1
Accepted
time: 6ms
memory: 3168kb

input:

500
33 289 30 214 325 168 269 25 333 17 415 20 220 436 338 181 469 374 335 109 282 489 171 149 290 352 26 333 297 343 73 215 307 93 34 94 366 51 206 261 281 223 474 477 146 172 123 264 476 281 174 113 8 184 494 239 187 228 490 104 378 399 362 313 125 137 164 131 141 117 337 459 475 327 431 346 439 2...

output:

185386945

result:

ok single line: '185386945'

Test #58:

score: 0
Accepted
time: 3ms
memory: 3164kb

input:

497
374 301 152 387 431 321 186 221 375 496 453 167 137 170 167 230 155 486 36 263 194 170 314 322 164 324 103 383 360 35 391 330 272 457 160 237 422 4 244 365 345 230 370 444 445 83 361 240 400 118 12 78 475 197 9 100 9 81 9 221 109 485 212 225 294 466 181 10 260 103 149 81 340 204 105 152 75 74 28...

output:

616520424

result:

ok single line: '616520424'

Test #59:

score: 0
Accepted
time: 3ms
memory: 3136kb

input:

495
399 199 478 354 477 221 63 350 3 247 72 339 23 335 324 296 354 360 62 333 111 289 173 19 220 191 494 281 483 87 107 75 14 111 438 3 267 474 217 88 438 305 493 297 495 492 425 432 128 452 251 131 378 28 91 243 127 80 171 204 376 119 53 319 63 393 298 41 303 242 205 4 127 169 500 477 424 286 107 1...

output:

767871328

result:

ok single line: '767871328'

Test #60:

score: 0
Accepted
time: 6ms
memory: 3052kb

input:

500
2 85 289 315 11 414 409 429 320 205 286 137 177 80 276 310 313 231 465 340 101 444 490 73 478 408 284 3 436 191 498 159 211 89 82 87 266 420 255 99 473 481 434 417 146 226 486 242 138 225 193 387 203 437 187 106 134 173 137 362 297 307 493 4 267 208 267 303 448 47 469 174 78 238 232 308 269 252 ...

output:

462261109

result:

ok single line: '462261109'

Test #61:

score: 0
Accepted
time: 8ms
memory: 3292kb

input:

500
3 5 3 61 485 228 26 8 4 50 1 5 19 1 3 1 316 5 2 1 4 1 3 1 1 227 146 77 286 12 2 37 3 119 61 88 8 367 3 80 55 1 386 1 6 117 12 6 29 1 1 91 38 1 1 8 13 102 5 290 1 4 1 1 46 1 2 38 3 52 6 114 64 1 3 10 4 14 1 2 1 171 1 1 1 8 1 111 218 1 435 1 1 30 4 6 217 121 21 38 2 38 13 111 283 59 1 16 5 2 24 4 ...

output:

428670198

result:

ok single line: '428670198'

Test #62:

score: 0
Accepted
time: 4ms
memory: 3056kb

input:

497
128 3 6 1 4 4 7 11 22 60 30 9 19 1 353 3 146 53 10 92 17 7 13 19 2 1 101 2 3 1 40 62 1 69 4 52 1 2 53 73 28 1 7 45 36 3 4 15 1 16 11 3 63 463 232 8 8 4 2 37 137 1 27 1 18 1 1 4 1 198 8 1 311 1 2 4 30 1 14 1 7 1 1 13 9 112 87 126 24 2 1 5 3 24 31 97 2 214 47 5 190 228 2 436 97 24 234 155 23 14 7 ...

output:

77949408

result:

ok single line: '77949408'

Test #63:

score: 0
Accepted
time: 8ms
memory: 3140kb

input:

500
1 107 36 1 1 55 1 1 13 71 56 56 1 1 2 1 64 3 9 23 43 3 1 97 1 36 19 3 1 1 2 1 34 41 3 255 93 9 20 2 250 5 2 105 23 9 7 2 81 20 55 40 5 1 8 7 17 1 192 64 3 102 2 2 1 14 1 61 55 123 6 19 1 3 3 7 6 1 16 73 2 5 2 2 4 1 3 3 4 2 1 430 1 83 3 34 2 2 105 1 1 108 1 2 8 1 2 5 63 2 21 24 61 73 6 1 482 1 2 ...

output:

166238891

result:

ok single line: '166238891'

Test #64:

score: 0
Accepted
time: 2ms
memory: 3268kb

input:

500
500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 ...

output:

983184552

result:

ok single line: '983184552'

Subtask #8:

score: 1
Accepted

Test #65:

score: 1
Accepted
time: 5ms
memory: 3156kb

input:

500
418 307 377 253 121 282 225 1 301 178 455 403 291 338 301 388 253 39 349 363 303 433 423 42 109 335 285 128 153 39 409 442 220 250 198 92 317 29 293 159 486 490 67 341 417 39 496 363 260 10 156 135 380 255 143 490 280 155 426 148 470 324 396 140 356 51 168 305 265 66 175 425 187 252 253 463 33 3...

output:

230008914

result:

ok single line: '230008914'

Test #66:

score: 0
Accepted
time: 6ms
memory: 3140kb

input:

499
130 47 243 441 72 217 418 460 456 436 448 5 428 7 108 27 303 483 278 172 362 382 461 14 106 454 105 234 341 36 217 92 362 468 191 108 357 387 61 403 491 392 306 395 367 323 365 206 125 451 218 274 442 141 294 179 316 438 267 376 214 208 109 469 428 486 350 216 104 263 69 264 92 484 32 182 386 21...

output:

922626867

result:

ok single line: '922626867'

Test #67:

score: 0
Accepted
time: 6ms
memory: 3056kb

input:

498
307 494 445 123 357 487 204 383 181 286 438 143 99 257 348 21 5 164 364 497 318 79 1 95 390 81 14 24 93 217 478 114 449 71 275 9 199 197 170 80 481 93 68 470 194 43 122 85 159 207 437 4 138 49 319 167 151 303 184 132 309 465 336 283 45 187 246 46 140 159 80 236 25 199 7 200 91 113 421 358 202 15...

output:

760780187

result:

ok single line: '760780187'

Test #68:

score: 0
Accepted
time: 6ms
memory: 3060kb

input:

500
26 492 399 477 346 360 282 205 390 420 52 98 415 80 445 266 285 247 213 471 67 354 310 431 263 323 129 244 111 239 101 175 145 140 112 342 143 147 375 461 477 460 425 54 313 145 379 310 462 304 74 421 395 254 317 127 141 440 334 230 381 75 280 352 130 417 419 463 236 274 157 299 405 263 238 89 8...

output:

480859678

result:

ok single line: '480859678'

Test #69:

score: 0
Accepted
time: 4ms
memory: 3144kb

input:

496
1 34 24 12 64 2 48 2 1 91 43 6 20 1 9 12 1 49 1 1 14 2 142 1 1 1 1 1 379 1 10 1 5 41 2 1 1 1 4 4 87 1 15 160 2 2 1 223 264 1 13 1 80 8 122 5 12 1 39 2 3 1 8 219 4 64 5 1 2 54 88 45 11 492 13 1 104 82 374 1 1 5 25 51 80 1 2 1 195 1 4 5 164 1 10 3 2 151 6 1 9 5 49 447 4 10 1 37 14 2 1 62 14 96 19 ...

output:

304393619

result:

ok single line: '304393619'

Test #70:

score: 0
Accepted
time: 8ms
memory: 3060kb

input:

495
229 77 1 1 8 1 1 3 1 1 496 17 1 1 1 5 8 12 20 1 2 43 8 3 2 1 2 2 195 1 1 52 23 22 1 1 70 176 171 26 90 139 1 2 80 91 1 1 337 151 91 103 2 2 2 4 47 366 1 26 1 28 36 2 2 4 481 65 5 463 8 2 136 66 13 1 1 27 1 15 6 11 1 143 393 499 4 9 66 52 178 11 1 75 2 3 228 99 1 209 1 55 7 2 4 1 1 253 7 21 176 1...

output:

642703729

result:

ok single line: '642703729'

Test #71:

score: 0
Accepted
time: 4ms
memory: 3136kb

input:

500
216 37 1 1 1 48 483 1 13 226 37 115 478 4 47 29 1 11 3 9 1 53 1 1 2 8 1 1 467 55 147 283 1 1 24 1 45 1 1 20 1 1 10 9 1 2 22 150 2 101 101 2 13 391 99 3 7 213 3 81 61 35 221 5 28 31 94 184 8 13 5 2 16 330 74 33 1 31 3 16 10 1 87 55 1 1 1 15 1 2 1 345 75 13 2 187 2 42 37 21 2 1 27 1 1 1 1 2 25 31 ...

output:

42146282

result:

ok single line: '42146282'

Test #72:

score: 0
Accepted
time: 6ms
memory: 2980kb

input:

500
51 308 248 13 365 112 412 28 401 451 478 227 201 280 437 448 34 157 387 42 225 335 85 357 72 110 106 223 389 442 109 447 93 258 69 204 265 500 252 77 47 27 96 453 269 243 23 260 155 103 136 160 450 431 215 481 378 192 206 498 56 235 261 284 158 369 229 274 231 360 200 90 367 14 376 181 25 327 23...

output:

734059940

result:

ok single line: '734059940'

Subtask #9:

score: 1
Accepted

Test #73:

score: 1
Accepted
time: 3ms
memory: 3344kb

input:

4997
3526 4209 3664 2914 1645 1057 3799 4819 4031 1361 2661 3732 4679 3741 2344 3796 3435 3886 756 243 579 2718 1300 3114 4598 2274 4843 1735 2096 4058 243 71 4691 2546 925 847 547 2316 1787 2769 2558 4986 981 3540 191 95 576 2696 1149 1149 689 698 3167 2695 4410 263 2181 1065 1649 2375 1685 217 347...

output:

0

result:

ok single line: '0'

Test #74:

score: 0
Accepted
time: 499ms
memory: 3484kb

input:

5000
380 377 4679 3107 2067 2276 2924 3934 4122 1040 1667 4618 2275 1740 919 2650 754 1934 3063 2857 85 4979 868 4834 1690 2600 3958 4850 2942 3231 1624 2752 2359 1888 4741 555 1608 1557 1761 2343 672 1435 2419 708 506 4157 2479 1205 320 3346 2662 4223 3525 3285 4349 3718 2631 4316 4022 2379 748 292...

output:

783944639

result:

ok single line: '783944639'

Test #75:

score: 0
Accepted
time: 484ms
memory: 3488kb

input:

5000
129 4663 1692 2610 3481 420 3294 906 2456 1140 2508 3436 2905 2416 1761 645 778 1273 1741 1739 4820 1030 3815 2300 4040 250 1006 2827 1298 2872 4719 3433 3911 1486 3921 4856 955 2080 3855 4711 2308 1442 3561 1767 4645 4153 3729 789 4227 1238 4124 4275 543 2744 989 2229 522 2100 4812 3176 1612 8...

output:

573155039

result:

ok single line: '573155039'

Test #76:

score: 0
Accepted
time: 476ms
memory: 3440kb

input:

5000
922 683 3714 2577 21 634 2326 1281 3142 2920 1162 2369 437 2374 4384 256 1343 3426 4731 1300 1815 4268 1266 1969 4977 1462 3835 1054 2816 1337 1401 818 2683 1616 304 120 1690 787 4373 1821 4028 4823 3490 1 948 4073 2976 1865 1468 4214 4523 4122 534 240 3410 1763 1084 3778 3334 1448 2267 1293 20...

output:

858409463

result:

ok single line: '858409463'

Test #77:

score: 0
Accepted
time: 899ms
memory: 3556kb

input:

5000
1050 27 30 1 46 1 125 4 2 10 7 195 236 8 336 174 4557 2 7 429 6 212 3 15 38 21 53 5 1 1 2736 23 1210 2006 3 1 113 249 1 1 507 2 1 1 13 12 431 142 42 1482 282 2 2 20 1318 1 354 13 984 14 186 89 1 150 14 12 20 436 3 2 453 826 2 15 62 1002 639 30 1 1293 113 1 230 130 38 241 12 51 4 7 4 223 53 6 86...

output:

511685275

result:

ok single line: '511685275'

Test #78:

score: 0
Accepted
time: 896ms
memory: 3572kb

input:

5000
2 3622 35 1510 47 1661 26 1874 1 30 1408 2 7 24 1 4394 523 97 84 8 447 2366 64 32 53 238 1 2 30 3499 1 1 1465 4 1 3 153 3 43 1 4631 262 144 1 736 1 1932 239 1367 586 656 1 1 709 39 8 695 1 51 221 3637 113 9 177 2 2634 23 113 1 37 9 1 118 304 1 1994 1009 104 404 60 433 1 23 6 48 45 109 2 2 1 356...

output:

180755107

result:

ok single line: '180755107'

Test #79:

score: 0
Accepted
time: 877ms
memory: 3572kb

input:

5000
1 376 2 6 2525 758 1 508 74 32 120 39 15 3 641 20 2043 4797 665 4779 24 1 2 323 1774 3 10 1873 64 2 1 105 215 157 428 201 4751 37 49 6 339 5 152 116 97 6 179 472 10 64 5 686 70 1 22 895 200 110 1960 4870 542 116 2779 220 102 467 1 6 1 406 55 2419 1 672 30 3258 3502 2 80 27 4 6 4 2 6 11 55 1 30 ...

output:

261849062

result:

ok single line: '261849062'

Test #80:

score: 0
Accepted
time: 4ms
memory: 3452kb

input:

5000
5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 ...

output:

405256386

result:

ok single line: '405256386'

Test #81:

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

input:

5000
5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 ...

output:

0

result:

ok single line: '0'

Subtask #10:

score: 1
Accepted

Test #82:

score: 1
Accepted
time: 1ms
memory: 3208kb

input:

5000
4922 3943 1439 2162 3269 4370 3133 2840 4877 1730 548 4639 4920 234 560 1920 549 1632 4606 1386 559 1739 1029 1931 4452 4368 909 1130 2231 1297 4386 3954 692 2128 3441 3871 4991 810 509 4354 2152 4634 1787 4263 1409 206 2491 1311 2264 1632 3652 3547 1351 4018 3919 649 2017 2910 3399 4574 1460 2...

output:

0

result:

ok single line: '0'

Test #83:

score: 0
Accepted
time: 490ms
memory: 3568kb

input:

4997
3458 653 3812 2260 377 3015 505 2348 2512 4002 2280 1996 2123 3219 4074 3515 2045 2370 2696 3407 3671 3162 4579 1321 4269 4669 3124 1428 2978 807 4235 1045 1211 1558 4648 2784 3110 992 4486 2169 2810 4135 2560 4749 3728 3857 3521 1014 2163 2986 3488 3884 4464 1152 4808 1806 1860 4643 371 462 29...

output:

366109506

result:

ok single line: '366109506'

Test #84:

score: 0
Accepted
time: 476ms
memory: 3576kb

input:

4995
4820 4940 60 4811 3800 2161 1328 826 4548 3394 1850 4509 3427 793 4434 4623 3762 4660 291 3471 4603 1683 4120 2506 2159 4723 2440 1264 4025 764 4985 1233 4844 1925 3649 4439 799 191 1070 1729 2409 1814 3943 575 286 3583 411 705 668 1143 340 368 570 2023 3401 4664 1352 1944 1526 2414 1013 2939 1...

output:

478123266

result:

ok single line: '478123266'

Test #85:

score: 0
Accepted
time: 481ms
memory: 3476kb

input:

5000
833 1927 663 1896 3116 2899 2962 2053 4879 4385 1635 4683 4491 750 661 223 787 4969 2756 2943 675 3829 599 455 3185 1064 2212 69 2445 967 2297 2470 141 4341 1066 2418 108 3007 3096 4058 2065 3893 1479 4062 718 3777 2497 874 1360 3091 2381 2660 2757 2748 1958 2690 4113 3676 1008 1241 3036 549 15...

output:

259246748

result:

ok single line: '259246748'

Test #86:

score: 0
Accepted
time: 891ms
memory: 3476kb

input:

5000
2850 1 60 3 2959 51 4422 898 282 53 131 4 72 361 1 313 2 40 98 60 39 5 237 39 289 369 4918 4 55 299 86 6 11 248 80 484 1 2 2280 24 2409 11 518 1 5 90 2 1 64 2 41 358 1 1 229 2506 4 77 16 58 322 3 12 1 3250 6 1 1 7 2 6 127 2 3 2 1 29 1 272 63 4027 117 218 990 116 2553 1 6 850 3 340 2 4100 218 31...

output:

324013510

result:

ok single line: '324013510'

Test #87:

score: 0
Accepted
time: 879ms
memory: 3432kb

input:

5000
1 346 178 2 556 1 21 2 223 2737 164 984 15 240 1 1 4 1328 233 121 7 16 1868 1390 84 7 621 69 381 1 185 13 30 4 1039 13 1 132 38 30 5 6 45 3 1 1 312 5 132 131 19 3434 4 95 18 407 163 5 1481 1 2 4 985 3 1152 503 3 1791 3866 64 163 151 19 391 14 1964 11 7 147 1504 1124 1335 101 5 3 2 21 1 3079 134...

output:

270858661

result:

ok single line: '270858661'

Test #88:

score: 0
Accepted
time: 874ms
memory: 3712kb

input:

5000
32 104 12 14 12 252 177 8 69 371 138 33 1109 106 2 1 873 563 3930 4008 4 3898 13 10 2 1601 1 247 2669 240 1 220 151 1 3 13 110 38 9 79 195 2 29 22 1410 700 4 2 2 11 1 121 3 4 413 1185 1 49 9 4639 4 965 289 279 1982 61 381 1 187 1 2842 111 1433 129 3 2533 2 14 61 101 1678 92 2 30 1 1 1 2 894 120...

output:

571110232

result:

ok single line: '571110232'

Test #89:

score: 0
Accepted
time: 3ms
memory: 3352kb

input:

5000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

860192574

result:

ok single line: '860192574'

Test #90:

score: 0
Accepted
time: 488ms
memory: 3448kb

input:

5000
3179 2391 386 606 4163 1292 3541 1944 4272 2595 4493 1767 3357 4166 3203 2111 2552 1596 539 4124 4935 2041 2313 4379 3921 2285 3348 4915 4449 2316 4020 4606 1620 2375 3060 40 4418 1644 4544 4919 2931 3193 2413 1760 3727 4928 3195 4699 2160 1580 4398 1564 215 4649 3505 2072 3106 4281 2697 543 27...

output:

110763317

result:

ok single line: '110763317'