QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#402387#8601. Герої та Монстриoscaryang33 29ms101896kbC++201.9kb2024-04-30 14:57:322024-04-30 14:57:32

Judging History

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

  • [2024-04-30 14:57:32]
  • 评测
  • 测评结果:33
  • 用时:29ms
  • 内存:101896kb
  • [2024-04-30 14:57:32]
  • 提交

answer

#include<bits/stdc++.h>

#define vc vector
#define pb emplace_back
#define pii pair<int, int>
#define mkp make_pair
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define lep(i, a, b) for(int i = (a); i >= (b); --i)

using namespace std;

mt19937 gen(time(0));

inline int read() {
	int x = 0, w = 0; char ch = getchar(); while(!isdigit(ch)) w |= (ch == '-'), ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar(); return w ? -x : x; 
}

const int N = 5005, MOD = 998244353;

// CALC
inline void inc (int &x, int y) { x += y - MOD; x += (x >> 31) & MOD; }
inline int qpow (int a, int b) { int res = 1; for(; b; b >>= 1, a = 1ll * a * a % MOD) if(b & 1) res = 1ll * res * a % MOD; return res; }
inline int qinv (int a) { return qpow(a, MOD - 2); }

struct mint {
	int x; 
	mint (int ix = 0) { x = ix % MOD; if(x < 0) x += MOD; }
	mint operator += (mint a) { inc (x, a.x); return a; }
	mint operator -= (mint a) { inc (x, MOD - a.x); return a; }
	mint operator *= (mint a) { x = 1ll * x * a.x % MOD; return a; }
	mint friend operator + (mint a, mint b) { a += b; return a; }
	mint friend operator - (mint a, mint b) { a -= b; return a; }
	mint friend operator * (mint a, mint b) { a *= b; return a; }
} ;  

int n, m, a[N], b[N];
mint ans[N], f[N][N];

inline mint calc (int t) {
	rep (i, 0, n) rep (j, 0, i) f[i][j] = 0;
	f[0][0] = 1;
	rep (i, 0, n - 1) rep (j, 0, min (i, t)) if (f[i][j].x) {
		if (a[i + 1] > b[j + 1]) f[i + 1][j + 1] += f[i][j];
		if (a[i + 1] < b[t + i - j + 1]) f[i + 1][j] += f[i][j];
	}
	return f[n][t];
}

signed main() {
	n = read ();
	rep (i, 1, n) a[i] = read ();
	rep (i, 1, n) b[i] = read ();
	sort (a + 1, a + 1 + n); sort (b + 1, b + 1 + n);
	
	rep (i, 0, n) ans[i + 1] = ans[i] + calc (i);
	
	m = read ();
	for (int i = 1, l, r; i <= m; i ++) {
		l = read (), r = read ();
		printf ("%d\n", (ans[r + 1] - ans[l]).x);
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

5000
1903 4400 1211 1700 2191 4378 4216 4601 2907 2029 3009 1858 4926 2981 2848 1345 689 4704 3137 51 1755 787 4679 1555 496 4259 3989 1122 3983 3966 3493 2869 4203 823 410 3144 738 41 3977 1767 2663 4779 3252 1930 4989 3003 1269 1604 3888 1737 3776 351 1035 4600 3740 1534 4846 2440 3725 838 76 2786...

output:


result:


Subtask #2:

score: 0
Time Limit Exceeded

Test #11:

score: 0
Time Limit Exceeded

input:

5000
2034 4850 3399 4589 4777 643 1832 1410 3705 2859 3002 1824 2063 2342 2885 1715 2531 2809 1389 1050 3167 374 242 368 4346 1850 3418 4129 4626 2762 1365 4440 3165 857 1042 61 713 2313 4467 2864 29 4725 4959 571 4753 378 4674 1960 1654 21 1704 4401 2068 3375 2092 2086 3004 4179 2865 2619 2873 4755...

output:


result:


Subtask #3:

score: 0
Time Limit Exceeded

Test #41:

score: 0
Time Limit Exceeded

input:

5000
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 17...

output:


result:


Subtask #4:

score: 16
Accepted

Test #71:

score: 16
Accepted
time: 21ms
memory: 101804kb

input:

300
127 142 125 327 217 438 162 129 16 370 452 170 418 357 397 446 398 597 5 296 558 159 140 566 433 132 302 565 472 513 477 198 350 467 177 160 272 155 251 440 84 176 387 112 237 578 258 278 26 74 332 6 136 400 367 273 535 146 252 141 11 484 285 465 474 512 373 462 480 207 505 580 114 22 340 42 288...

output:

268091962

result:

ok 1 number(s): "268091962"

Test #72:

score: 16
Accepted
time: 18ms
memory: 101700kb

input:

300
75 246 271 139 176 262 248 399 279 268 155 188 542 475 177 201 41 29 107 467 555 216 134 308 583 278 225 359 162 441 166 179 288 235 490 465 364 356 73 275 260 491 46 96 5 276 526 533 502 593 251 564 135 104 575 223 431 319 181 283 109 362 149 265 34 429 500 307 590 468 95 444 122 442 297 282 22...

output:

608937071

result:

ok 1 number(s): "608937071"

Test #73:

score: 16
Accepted
time: 16ms
memory: 101832kb

input:

300
153 459 260 428 101 245 480 292 91 457 487 574 368 64 421 263 175 588 333 278 381 546 93 259 104 179 16 238 413 177 189 559 129 46 123 340 550 439 148 128 97 44 553 137 592 12 598 571 24 548 485 305 573 251 204 71 520 308 549 321 326 415 359 557 491 521 526 11 387 533 200 50 407 589 380 75 54 23...

output:

398559783

result:

ok 1 number(s): "398559783"

Test #74:

score: 16
Accepted
time: 12ms
memory: 101752kb

input:

300
301 72 161 223 180 157 3 86 88 52 48 257 510 379 286 435 578 236 383 333 491 484 235 535 265 313 328 277 82 284 549 44 599 102 131 370 47 178 541 478 576 464 216 241 22 400 77 389 121 598 532 479 369 552 360 418 503 596 15 542 404 567 35 587 273 577 386 260 412 279 21 561 219 78 457 105 460 419 ...

output:

652953640

result:

ok 1 number(s): "652953640"

Test #75:

score: 16
Accepted
time: 22ms
memory: 101752kb

input:

300
486 100 549 299 303 233 361 520 222 247 582 584 408 463 201 115 14 209 205 203 281 512 358 527 369 536 282 560 234 528 182 300 109 387 156 204 101 54 539 452 283 274 302 92 440 379 9 498 483 472 179 507 231 598 314 116 97 256 325 447 134 184 430 295 370 373 437 257 206 538 543 266 200 190 294 30...

output:

397817158

result:

ok 1 number(s): "397817158"

Test #76:

score: 16
Accepted
time: 18ms
memory: 101696kb

input:

300
331 285 561 45 81 154 562 302 492 165 102 201 454 33 175 591 390 136 23 101 230 152 506 333 442 103 567 537 499 569 364 222 231 115 346 226 352 576 233 137 369 113 580 554 88 371 19 578 423 426 200 456 90 383 47 53 598 303 354 6 568 425 515 463 400 433 566 169 251 260 521 287 206 264 493 236 73 ...

output:

917575670

result:

ok 1 number(s): "917575670"

Test #77:

score: 16
Accepted
time: 21ms
memory: 101716kb

input:

300
176 36 33 121 449 178 10 335 79 141 306 462 372 425 393 472 325 354 157 593 427 327 329 493 424 548 37 339 590 367 466 31 251 45 43 199 6 102 441 565 77 283 149 555 281 546 309 261 544 332 487 516 221 73 381 86 20 358 235 598 574 459 298 46 453 390 92 115 241 259 61 280 504 343 208 484 371 486 2...

output:

368079261

result:

ok 1 number(s): "368079261"

Test #78:

score: 16
Accepted
time: 12ms
memory: 101752kb

input:

300
516 270 523 59 297 34 447 21 125 517 374 95 205 582 165 84 52 146 443 85 347 225 62 316 490 283 333 468 158 511 239 503 92 215 576 405 528 286 416 537 356 579 17 163 185 301 577 97 566 26 593 379 384 193 208 391 267 462 54 242 373 190 182 598 197 159 331 117 83 15 169 438 202 281 592 33 207 221 ...

output:

126430440

result:

ok 1 number(s): "126430440"

Test #79:

score: 16
Accepted
time: 23ms
memory: 101776kb

input:

300
592 587 144 183 365 223 449 318 193 90 131 524 523 13 549 416 349 504 74 38 536 14 143 124 483 216 436 211 388 267 394 328 217 256 29 552 520 237 116 313 586 236 422 314 438 323 146 522 406 7 514 570 432 575 437 539 254 135 153 58 145 12 492 95 32 172 598 269 2 551 87 54 357 450 26 521 173 577 2...

output:

840380815

result:

ok 1 number(s): "840380815"

Test #80:

score: 16
Accepted
time: 16ms
memory: 101776kb

input:

300
192 85 313 267 222 100 213 32 209 195 498 276 9 247 102 23 441 193 86 147 355 600 159 523 113 532 341 70 219 333 566 576 197 69 4 143 489 135 401 156 533 254 199 436 553 398 271 575 251 201 2 248 82 504 565 482 400 332 226 457 52 11 157 208 72 46 60 1 420 598 246 402 118 132 154 475 472 45 403 4...

output:

347978310

result:

ok 1 number(s): "347978310"

Test #81:

score: 16
Accepted
time: 20ms
memory: 101700kb

input:

300
296 548 522 323 360 470 423 286 449 239 67 46 358 26 32 451 230 582 254 578 241 248 556 170 540 463 338 581 535 36 471 401 343 523 40 403 393 173 541 526 575 301 528 21 273 427 421 437 264 190 426 519 280 315 509 373 345 485 212 399 436 321 367 53 179 117 45 513 469 122 546 134 355 598 411 590 4...

output:

844737740

result:

ok 1 number(s): "844737740"

Test #82:

score: 16
Accepted
time: 13ms
memory: 101752kb

input:

300
59 373 212 419 334 304 368 557 439 207 123 413 476 266 92 303 405 562 509 289 138 49 568 193 504 111 315 65 471 254 437 305 527 438 136 498 30 464 543 112 290 171 382 283 202 17 247 157 406 431 18 378 446 258 361 96 182 104 494 451 319 490 268 38 234 547 563 140 70 291 169 295 84 161 153 98 54 2...

output:

512304538

result:

ok 1 number(s): "512304538"

Test #83:

score: 16
Accepted
time: 21ms
memory: 101772kb

input:

300
392 460 349 522 375 85 438 288 471 24 195 223 167 211 254 355 47 582 141 43 361 443 115 22 80 69 106 253 48 263 567 383 73 321 38 90 393 234 347 17 216 518 218 560 179 442 278 387 425 372 388 577 138 529 165 35 166 580 261 135 533 504 269 64 108 159 116 41 398 404 87 266 543 459 358 363 237 30 5...

output:

342542654

result:

ok 1 number(s): "342542654"

Test #84:

score: 16
Accepted
time: 22ms
memory: 101840kb

input:

300
425 287 348 278 490 548 116 520 531 276 367 396 47 293 167 571 583 12 444 118 505 593 19 277 437 465 151 30 103 281 407 586 462 81 139 417 289 256 190 461 192 14 186 463 283 567 470 229 269 101 491 114 120 476 222 91 168 550 565 201 66 5 110 502 231 298 390 450 587 144 145 94 427 228 198 266 209...

output:

832931580

result:

ok 1 number(s): "832931580"

Test #85:

score: 16
Accepted
time: 11ms
memory: 101780kb

input:

300
89 492 430 92 432 527 504 556 114 60 580 414 156 387 459 469 167 240 355 73 307 496 335 119 161 507 103 402 283 192 139 295 65 436 138 71 190 162 409 340 303 389 231 13 531 585 70 293 517 516 341 20 593 403 356 21 218 550 281 250 573 196 443 91 408 513 431 329 27 382 179 90 228 251 327 465 548 2...

output:

888614727

result:

ok 1 number(s): "888614727"

Test #86:

score: 16
Accepted
time: 20ms
memory: 101764kb

input:

300
481 560 98 271 359 171 356 181 473 146 22 403 482 194 137 362 113 563 437 17 452 582 529 574 205 498 305 329 243 339 207 14 486 250 152 11 83 352 64 198 267 166 27 26 571 132 432 172 412 279 545 188 535 289 593 226 395 550 454 100 214 110 409 385 85 526 141 227 249 149 507 328 154 282 54 74 169 ...

output:

399268766

result:

ok 1 number(s): "399268766"

Test #87:

score: 16
Accepted
time: 18ms
memory: 101828kb

input:

300
591 215 440 133 420 442 110 555 511 175 240 252 561 357 20 401 334 592 36 135 198 324 94 139 213 359 190 438 499 557 117 185 374 544 321 141 75 581 229 44 264 422 589 235 424 282 487 258 130 162 78 474 393 514 18 150 158 116 14 257 8 166 105 113 188 339 558 50 509 89 316 192 456 565 65 320 174 2...

output:

76869128

result:

ok 1 number(s): "76869128"

Test #88:

score: 16
Accepted
time: 12ms
memory: 101832kb

input:

300
298 453 390 342 141 456 590 78 121 114 370 437 11 283 223 60 428 66 362 360 455 233 312 466 414 457 140 222 126 73 185 319 589 513 447 568 520 269 413 332 563 352 316 572 418 158 359 164 265 541 227 32 294 53 492 392 63 6 483 385 522 110 446 5 577 461 303 175 309 159 289 50 571 261 508 122 584 3...

output:

918908630

result:

ok 1 number(s): "918908630"

Test #89:

score: 16
Accepted
time: 11ms
memory: 101780kb

input:

300
52 509 25 240 463 160 587 170 313 319 108 422 273 69 50 16 190 11 205 100 311 579 202 228 30 109 280 3 74 7 124 405 48 127 569 402 472 98 597 370 505 72 332 469 42 235 381 241 538 270 464 390 548 1 263 298 173 394 562 2 320 253 496 164 219 139 518 260 362 546 242 182 296 29 323 187 363 416 554 1...

output:

707412529

result:

ok 1 number(s): "707412529"

Test #90:

score: 16
Accepted
time: 15ms
memory: 101712kb

input:

300
56 292 426 176 133 437 51 419 143 59 3 554 420 215 356 534 451 243 165 52 270 305 515 228 542 485 86 473 353 533 429 475 70 237 202 5 97 375 303 532 259 556 153 570 312 352 6 203 476 137 93 62 411 245 463 269 300 19 405 380 491 196 563 348 538 4 145 279 370 138 33 271 136 530 334 438 488 226 591...

output:

879408664

result:

ok 1 number(s): "879408664"

Test #91:

score: 16
Accepted
time: 15ms
memory: 101768kb

input:

300
33 513 74 309 340 407 486 308 275 210 100 127 60 95 540 491 115 173 385 292 237 226 167 245 70 494 132 23 489 43 118 273 323 534 20 470 78 411 317 450 220 269 333 154 48 320 271 438 343 133 430 575 266 250 369 162 261 16 444 256 209 357 506 208 285 508 68 32 360 104 471 58 147 482 478 400 451 17...

output:

708291707

result:

ok 1 number(s): "708291707"

Test #92:

score: 16
Accepted
time: 12ms
memory: 101736kb

input:

300
342 306 199 185 437 546 94 389 172 237 589 230 357 212 398 295 111 441 435 510 337 324 282 224 232 211 347 547 457 155 470 174 265 391 302 451 385 524 448 358 408 473 121 569 543 359 321 248 348 440 77 308 269 522 406 67 273 461 11 319 128 5 379 179 382 300 599 310 346 238 555 122 387 309 351 33...

output:

370497285

result:

ok 1 number(s): "370497285"

Test #93:

score: 16
Accepted
time: 12ms
memory: 101772kb

input:

300
302 536 511 509 71 90 556 136 337 360 255 173 46 252 562 413 463 248 277 498 593 407 487 331 74 52 22 207 196 244 465 43 39 160 120 245 390 456 289 353 479 271 301 489 183 491 250 246 226 59 238 371 119 166 410 7 597 394 481 20 178 532 201 525 286 404 364 121 44 356 400 158 127 8 146 266 179 543...

output:

6315369

result:

ok 1 number(s): "6315369"

Test #94:

score: 16
Accepted
time: 19ms
memory: 101776kb

input:

300
315 491 98 510 548 119 176 78 522 145 267 168 126 62 313 319 69 599 117 115 260 356 102 200 132 573 497 241 215 547 383 20 377 236 75 542 364 417 446 488 412 578 46 472 553 352 36 424 554 561 492 593 298 94 44 526 305 309 184 201 521 482 230 224 278 15 463 312 308 6 71 582 244 338 588 29 221 227...

output:

35127377

result:

ok 1 number(s): "35127377"

Test #95:

score: 16
Accepted
time: 18ms
memory: 101824kb

input:

300
376 214 428 386 432 339 444 262 309 208 168 100 427 273 95 255 34 39 519 50 290 248 68 264 344 160 330 5 368 275 276 141 132 516 32 71 374 590 540 195 22 400 220 209 62 440 256 98 200 592 127 416 455 185 252 357 269 138 306 343 177 307 325 326 152 410 12 125 60 210 231 106 407 392 398 548 373 56...

output:

781892224

result:

ok 1 number(s): "781892224"

Test #96:

score: 16
Accepted
time: 15ms
memory: 101748kb

input:

300
391 389 144 299 104 79 155 118 436 464 286 583 488 66 466 62 133 72 306 341 112 476 260 450 535 135 200 126 67 568 484 297 65 425 244 584 572 167 533 166 218 588 325 378 517 131 432 350 506 352 596 560 311 40 557 461 575 360 525 452 473 227 103 296 22 383 361 443 6 187 540 441 594 578 47 280 485...

output:

429733454

result:

ok 1 number(s): "429733454"

Test #97:

score: 16
Accepted
time: 17ms
memory: 101768kb

input:

300
280 471 211 236 92 347 388 469 293 494 130 550 77 233 538 41 485 545 160 268 237 585 394 325 586 436 342 227 231 304 569 447 361 544 348 209 318 401 343 360 210 270 246 82 27 467 588 168 207 575 464 408 319 70 3 451 34 199 251 566 103 400 17 83 521 73 21 61 229 43 324 289 341 249 582 404 89 356 ...

output:

643377604

result:

ok 1 number(s): "643377604"

Test #98:

score: 16
Accepted
time: 11ms
memory: 101836kb

input:

300
52 325 207 225 146 294 484 520 588 362 89 550 574 226 304 53 431 318 300 111 480 390 412 408 403 377 139 118 340 358 538 67 230 105 99 204 170 261 143 249 556 167 440 436 79 495 274 262 201 159 137 305 47 430 352 38 134 545 66 42 579 513 476 13 97 555 46 402 15 368 475 373 391 24 276 288 200 511...

output:

318544610

result:

ok 1 number(s): "318544610"

Test #99:

score: 16
Accepted
time: 17ms
memory: 101700kb

input:

300
405 290 119 87 527 429 424 136 487 560 227 162 172 588 127 281 366 329 386 470 229 469 256 109 475 95 20 314 313 497 245 151 494 400 28 241 65 581 493 134 499 566 413 354 321 269 11 538 217 191 422 548 298 200 525 264 491 131 236 496 552 7 242 13 159 522 54 219 573 112 30 390 460 125 393 130 387...

output:

355636567

result:

ok 1 number(s): "355636567"

Test #100:

score: 16
Accepted
time: 19ms
memory: 101708kb

input:

300
245 121 99 354 336 145 295 404 292 9 76 491 529 465 97 253 220 141 139 98 347 462 105 219 189 174 234 346 61 85 375 502 416 154 286 232 456 477 583 381 156 324 201 409 396 215 193 332 153 3 198 294 212 551 40 280 483 211 34 96 302 537 100 124 366 78 119 569 315 521 67 349 353 364 94 581 338 582 ...

output:

44265214

result:

ok 1 number(s): "44265214"

Subtask #5:

score: 0
Time Limit Exceeded

Test #101:

score: 0
Time Limit Exceeded

input:

5000
214 8143 377 4551 6212 1807 4966 4535 3579 997 7830 3921 7330 6511 8039 1554 3258 9014 4821 7807 1039 7535 4022 2642 2781 8442 3246 141 9033 2806 9569 8010 565 2546 6114 7896 4315 3054 384 1100 9263 9236 8117 8983 8184 2987 5491 8267 1271 5488 3990 494 2917 6363 3528 8154 3334 4216 8742 2805 53...

output:


result:


Subtask #6:

score: 0
Time Limit Exceeded

Test #131:

score: 0
Time Limit Exceeded

input:

5000
3846 2428 4235 4639 1041 2385 198 6154 6899 8917 6284 9752 8913 2027 9242 6979 498 2562 5915 3968 9943 2767 3776 3415 3532 1826 8061 9507 6540 1850 2235 7245 5751 5780 3048 23 361 2777 262 8551 4969 1367 8671 7424 504 5822 3056 6816 9246 6810 1643 8378 9672 7472 4092 8226 5973 157 9275 4757 619...

output:


result:


Subtask #7:

score: 17
Accepted

Dependency #4:

100%
Accepted

Test #161:

score: 17
Accepted
time: 12ms
memory: 101708kb

input:

300
191 165 526 38 537 109 12 210 506 123 516 340 49 81 181 208 186 87 39 318 381 540 9 565 312 536 183 204 313 164 291 258 472 205 132 511 497 242 379 263 393 236 539 590 41 473 504 23 234 566 422 440 427 546 148 374 16 255 317 356 221 195 352 228 249 273 30 416 198 428 300 551 534 75 133 158 188 3...

output:

273132513
887672688
409288709
142455919
773484598
317630612
804060490
856508392
557665061
75327539
874391513
12751682
619560322
685590351
41963476
518972526
578870954
365846076
747713799
73288435
461104624
305773533
584124575
385013863
616587895
696967390
268476696
789289888
973454496
773028995
3606...

result:

ok 301 numbers

Test #162:

score: 17
Accepted
time: 15ms
memory: 101776kb

input:

300
345 333 529 502 81 16 557 20 149 396 43 359 568 223 90 24 524 405 595 202 350 214 96 14 556 368 220 585 257 295 249 85 110 594 584 103 355 222 144 308 162 75 122 23 233 456 387 101 127 287 500 335 523 540 340 180 58 510 166 32 217 240 535 496 415 147 285 48 232 183 379 317 458 169 382 412 152 25...

output:

322266516
325315118
353389289
284167591
982946575
220325534
0
323634953
366065386
857374154
585611911
33917891
585706241
764631702
464675016
974996048
575035369
32750369
211481913
984692997
789975730
29359370
816545224
301957097
709575667
657891101
614464899
118224472
642467638
252171351
420240944
8...

result:

ok 301 numbers

Test #163:

score: 17
Accepted
time: 19ms
memory: 101896kb

input:

300
62 7 352 333 353 370 266 555 481 429 196 262 399 99 483 482 537 377 181 378 190 47 446 85 189 495 433 449 428 200 471 566 359 365 223 168 347 300 448 594 170 27 275 470 98 401 312 304 384 554 411 43 227 480 553 301 41 278 134 592 222 315 274 523 443 544 244 362 250 108 203 329 176 323 128 296 38...

output:

702578073
163778045
52401258
126688349
568937351
987965321
323769903
406404617
880027167
78356538
736332407
271492223
230740709
193264238
744303334
328919728
795992158
839830357
690302379
880285925
143703827
36128888
724810850
946306678
266731447
109675167
882353489
622795517
459271845
706232516
124...

result:

ok 301 numbers

Test #164:

score: 17
Accepted
time: 18ms
memory: 101772kb

input:

300
597 102 360 280 333 83 507 563 544 391 471 543 570 303 552 517 36 421 465 424 462 491 273 30 165 1 127 505 541 237 561 436 131 551 370 411 518 144 355 245 115 510 542 447 580 413 565 417 459 599 251 201 96 399 240 22 130 394 253 464 271 281 270 246 141 255 326 432 284 23 494 157 136 523 238 142 ...

output:

772308400
608630973
573917825
985275200
455686080
415809880
224576884
95587936
313515453
117121661
441234274
356855988
372995213
195816338
247390942
856332618
761138382
880820652
71983779
435240917
31204981
402574428
838568236
472832138
855501449
750861807
398945383
815586899
416062621
712556559
541...

result:

ok 301 numbers

Test #165:

score: 17
Accepted
time: 23ms
memory: 101772kb

input:

300
532 80 375 55 62 300 558 352 256 271 164 185 43 566 514 156 527 250 304 536 509 188 545 336 286 235 330 234 490 449 579 200 323 270 86 576 493 487 437 88 390 419 112 518 144 543 197 587 436 194 261 502 365 182 403 381 393 267 106 539 145 90 100 406 473 172 462 368 465 2 51 63 48 218 467 210 455 ...

output:

704778339
222204069
512737185
361186579
514227588
92674712
37190650
796334974
404395491
150530199
445326531
961946184
878562465
174247982
383463641
262373488
463156892
2557019
558515256
445108198
703115734
228529620
828986362
251490620
12105848
979865767
861764725
327321568
660773470
826960256
47454...

result:

ok 301 numbers

Test #166:

score: 17
Accepted
time: 12ms
memory: 101780kb

input:

300
599 423 503 453 127 593 155 492 333 135 173 222 442 228 438 312 571 383 82 356 246 454 30 260 335 595 258 486 194 563 267 310 452 263 574 62 29 306 389 497 355 199 313 16 153 48 277 84 213 416 18 301 144 40 484 259 241 412 160 97 461 5 545 588 166 422 436 78 44 146 243 266 90 19 398 396 86 36 30...

output:

242719505
244021026
429825703
718159725
389947087
534402960
350916865
540720807
393390453
665035742
215855745
464303339
871345738
877140794
595844362
906495577
0
363464057
697127041
23683290
109876589
242370568
862707026
22545380
376316718
989806867
752702781
952724684
636323903
452166654
599811959
...

result:

ok 301 numbers

Test #167:

score: 17
Accepted
time: 11ms
memory: 101780kb

input:

300
448 419 274 267 174 313 350 62 122 377 284 450 232 583 105 451 223 113 26 212 204 87 133 39 300 466 511 118 71 168 109 506 576 200 533 18 593 207 599 282 172 397 404 526 440 366 165 161 99 179 360 88 257 314 92 272 59 121 556 280 295 565 591 211 69 251 237 418 588 37 160 114 365 424 208 597 489 ...

output:

11872440
656454887
376435011
803421104
918392619
667071742
747557783
566437210
979411360
207642068
625307402
862376500
494479136
605797202
218738287
231166993
712298113
200970647
791984654
208449072
892413117
225279652
534873759
926044793
52887527
674893271
125131754
486780201
99592326
997648140
990...

result:

ok 301 numbers

Test #168:

score: 17
Accepted
time: 15ms
memory: 101772kb

input:

300
433 51 559 156 192 47 188 214 310 125 510 367 74 141 347 181 3 98 106 340 183 176 298 61 372 568 175 142 168 251 588 296 264 421 272 502 245 312 522 321 515 101 21 426 384 571 91 30 194 23 174 383 50 575 256 549 150 269 596 284 185 10 179 585 578 444 81 593 531 423 478 332 594 288 258 100 482 43...

output:

10904335
581198053
590001461
901572073
892195950
854853409
638248066
249021864
886371978
270053834
691353634
72904788
522822014
483443694
569118913
494740233
404514121
420493518
334011073
444053651
456247555
593936543
915152739
904191323
894810282
971256301
747473108
598745528
432099673
522849489
31...

result:

ok 301 numbers

Test #169:

score: 17
Accepted
time: 23ms
memory: 101812kb

input:

300
248 363 150 105 45 362 464 98 226 469 261 303 344 596 592 352 108 243 91 231 351 22 216 581 297 437 287 549 299 576 276 446 573 449 64 588 584 14 80 441 311 485 81 132 100 254 575 73 286 528 97 126 187 50 117 555 354 177 310 138 492 21 478 183 42 560 229 550 47 93 112 292 147 332 527 356 539 594...

output:

210167259
588996826
414607013
509389267
974303127
326044002
817681174
804998734
20690393
184399655
747044527
227340795
251043950
438291486
263509953
52596316
322588549
796745844
255811568
308272052
195550964
608644534
197436054
61566497
89103318
322990167
71120257
980511342
155001273
316288820
66318...

result:

ok 301 numbers

Test #170:

score: 17
Accepted
time: 19ms
memory: 101828kb

input:

300
421 220 17 390 409 6 443 338 406 228 535 425 593 247 422 376 47 313 149 380 587 561 42 456 46 457 566 57 306 77 349 449 278 98 594 140 33 324 392 598 320 507 171 183 596 141 479 173 428 64 201 365 344 495 597 60 59 317 85 285 580 224 467 237 202 451 132 255 364 510 128 265 399 155 187 169 544 46...

output:

184137893
604353441
48362205
718287647
963981564
470011660
398591124
885610817
844153248
463338233
718794110
609884535
362252886
518864058
493836381
301465728
324400287
78565670
58267569
914785060
278834817
90120067
943760783
344332785
463143143
872149718
995922780
676340723
24223471
148083992
62328...

result:

ok 301 numbers

Test #171:

score: 17
Accepted
time: 21ms
memory: 101756kb

input:

300
145 134 527 462 541 167 79 104 542 228 293 182 454 465 161 54 436 223 211 544 336 78 123 482 18 586 75 473 113 420 395 503 198 304 63 265 515 2 301 364 315 43 126 598 91 273 402 277 136 249 204 243 488 390 505 553 122 356 241 268 334 452 400 152 203 225 82 39 276 579 563 342 539 140 240 202 576 ...

output:

166624932
152217900
223493797
888656959
740466774
470155239
124251401
980489471
828529859
59244496
919707593
237455285
361194031
836426077
764537848
620997951
541838358
874003644
852818298
156109745
888081364
18127759
962580048
107616660
712597353
181190978
349833721
456236729
732312930
994902022
72...

result:

ok 301 numbers

Test #172:

score: 17
Accepted
time: 19ms
memory: 101824kb

input:

300
536 88 529 187 269 353 428 489 566 356 484 213 574 549 453 95 245 288 459 262 89 580 101 444 513 320 440 116 23 581 502 441 196 449 436 25 261 162 180 41 585 193 309 195 293 46 598 490 259 463 79 537 512 83 582 346 181 260 368 517 142 455 290 130 345 347 281 411 373 149 365 474 589 593 516 398 1...

output:

234530310
146199703
576359358
579733062
420714391
734891930
466510242
708212070
816408566
391252295
712772184
788350269
119075036
22648882
12243699
934352784
15116385
704313358
265397535
123277185
958543600
356594995
378483557
408926864
467607919
388621035
974395188
266499772
461270473
202324374
288...

result:

ok 301 numbers

Test #173:

score: 17
Accepted
time: 26ms
memory: 101832kb

input:

300
497 505 482 170 69 101 288 399 560 332 439 18 3 334 103 375 562 14 515 244 17 57 384 516 77 584 62 378 175 117 130 546 148 174 400 552 360 24 571 4 156 50 397 89 15 145 27 143 450 598 268 184 321 11 97 205 81 427 541 422 59 322 589 1 354 206 511 581 500 492 330 498 119 576 213 475 64 586 566 199...

output:

776572625
861866188
548065473
940686724
188877761
866414585
262930574
561114271
845125349
222336877
323527246
505498968
939541828
800485060
916157613
120918095
878586716
394641526
212578198
673831196
785240157
788105833
478315406
779768408
249665197
660446233
668313309
825693914
72964908
199818613
2...

result:

ok 301 numbers

Test #174:

score: 17
Accepted
time: 18ms
memory: 101716kb

input:

300
341 94 273 50 583 471 193 185 100 333 320 236 332 292 342 414 421 297 26 531 543 35 221 372 322 254 309 447 14 475 39 154 91 75 449 469 420 443 510 526 8 398 285 182 6 358 140 158 399 286 78 557 298 598 101 495 391 364 432 385 250 56 594 537 18 139 170 65 403 439 562 197 4 558 433 440 218 82 280...

output:

741574237
268697668
195637869
5193683
568579915
945632538
672764580
747501640
689410905
977932706
338264011
314125416
725614699
147890771
819999880
329442724
719091027
483433682
935191538
914756070
323956356
247970766
929551053
2296842
926195699
57959994
378010925
582416103
926894525
657198382
62751...

result:

ok 301 numbers

Test #175:

score: 17
Accepted
time: 15ms
memory: 101832kb

input:

300
71 89 249 280 520 411 476 504 441 532 481 13 252 491 332 123 131 277 247 483 380 563 31 568 58 514 346 362 39 422 88 313 292 512 493 276 464 207 16 60 413 591 535 106 430 423 473 548 74 2 80 48 34 341 543 92 598 496 494 231 566 188 337 373 86 484 107 571 594 77 576 284 206 6 229 18 335 197 502 3...

output:

380170451
165637193
404394005
19986474
504362790
827239990
236529866
927862787
660136485
85895848
969666660
51352979
542881083
726323278
73027337
232676393
383938909
811679896
557444195
483214779
411391896
529933998
283984129
317212455
276642892
638148817
364390559
511002988
227665815
250125053
8478...

result:

ok 301 numbers

Test #176:

score: 17
Accepted
time: 25ms
memory: 101700kb

input:

300
461 314 521 121 267 383 533 288 250 556 99 338 368 452 1 289 339 356 136 111 122 330 510 370 89 244 39 226 351 418 82 18 312 500 388 74 449 231 390 480 106 528 76 290 504 97 295 151 277 469 337 181 214 270 160 424 169 186 474 598 260 574 31 542 333 453 236 107 209 232 184 308 419 102 505 378 423...

output:

160995900
298617332
193519765
563387628
407350407
66247194
599912542
425575443
283912737
177499380
758801546
168823140
611690286
681413543
275217034
697031858
207803830
622283878
787578058
441639863
526331333
491526893
791994367
880328898
792185432
456016524
212658975
660987032
688080639
966687385
6...

result:

ok 301 numbers

Test #177:

score: 17
Accepted
time: 25ms
memory: 101772kb

input:

300
197 222 550 247 27 388 359 477 202 165 163 232 565 367 302 428 142 231 327 357 573 456 32 171 209 400 233 58 414 24 9 140 73 130 587 499 392 257 77 337 474 484 572 563 420 442 96 275 164 351 65 261 370 485 252 187 546 401 495 210 155 71 561 412 263 192 576 554 481 292 377 440 159 177 112 457 364...

output:

396682168
116825693
860703114
779322373
96965857
71307832
74268130
140910523
385778308
601843524
393341295
248110305
820867853
557497769
556425486
251471439
919285174
50211146
685348901
405059135
626694113
889629297
307992435
865105104
627991470
557883215
623991714
296486004
220855955
66879880
28608...

result:

ok 301 numbers

Test #178:

score: 17
Accepted
time: 17ms
memory: 101712kb

input:

300
590 415 550 497 541 138 197 555 35 203 74 330 294 306 512 93 194 552 459 202 187 505 451 391 357 540 126 359 468 33 509 583 421 498 506 241 179 129 597 560 383 98 393 9 156 230 361 8 137 105 139 425 11 253 312 115 553 324 373 300 25 170 507 482 173 297 551 503 570 351 220 43 557 533 477 585 252 ...

output:

286909914
347145482
12406286
147711855
310072904
926431768
817328307
305029719
305029719
355249202
789182331
175381519
498167982
52235733
33705988
879821659
60873651
971239014
394010447
820359616
313502004
160089267
170319717
541238172
991954243
646300870
557034345
423824977
802527076
558850866
7145...

result:

ok 301 numbers

Test #179:

score: 17
Accepted
time: 14ms
memory: 101780kb

input:

300
23 579 276 425 163 89 295 521 486 235 104 415 402 470 385 167 337 40 53 9 34 109 119 363 566 55 458 291 248 325 282 244 216 520 345 62 350 138 64 353 394 145 303 265 547 558 3 528 359 455 211 6 298 406 18 185 79 540 511 530 83 408 441 576 397 172 563 323 348 333 230 343 148 91 327 131 251 102 34...

output:

347401273
350829959
915846356
898403525
681195068
388128180
346974725
604073636
862328424
846775273
100155962
648117638
392808636
851744709
133076028
0
235142558
865392725
748207732
650167981
502797695
593811902
897420003
605278134
511955953
828528401
264479519
222551552
83479631
739134640
796545
50...

result:

ok 301 numbers

Test #180:

score: 17
Accepted
time: 12ms
memory: 101696kb

input:

300
578 445 487 587 424 476 388 561 258 364 344 592 505 406 59 550 518 413 583 9 66 67 512 390 481 396 30 291 284 455 211 466 385 317 148 139 305 35 137 14 354 503 451 221 196 510 200 156 206 365 345 373 168 573 408 312 285 426 140 267 325 471 379 143 254 498 145 514 98 48 440 593 259 448 56 175 299...

output:

736226975
878887143
985335083
418301216
79232795
721529977
380620974
866490551
664000387
359671299
38179502
940775640
986753397
743677550
959081153
647607478
637609953
646677656
64603220
202777885
523328031
207419079
618277915
190067174
459334727
316354797
89358666
424886848
93918327
731388432
79929...

result:

ok 301 numbers

Test #181:

score: 17
Accepted
time: 16ms
memory: 101772kb

input:

300
354 153 93 68 189 41 470 310 355 363 87 434 328 445 152 519 110 415 213 74 90 222 372 230 266 112 534 224 346 484 515 302 267 579 446 181 419 537 28 21 67 471 494 31 7 348 317 232 201 314 223 421 457 369 347 236 123 5 122 291 439 286 154 521 395 522 88 460 62 290 548 200 390 593 412 268 228 143 ...

output:

238450218
473649112
735498544
375171294
453067823
6817730
228147305
613626885
163201607
832591754
652087806
38273859
915531058
0
321216665
443934951
133908321
195719968
330562686
425307454
776108040
129997921
617287597
104027082
874985702
198078546
804051156
510385937
898073289
713907239
460382970
7...

result:

ok 301 numbers

Test #182:

score: 17
Accepted
time: 15ms
memory: 101716kb

input:

300
180 306 485 336 112 73 267 74 189 434 15 202 577 184 108 533 192 132 357 48 393 471 399 8 123 445 369 386 415 11 526 578 331 597 519 539 38 379 283 368 26 85 428 209 534 219 476 427 430 363 276 259 23 513 456 206 407 396 225 516 355 4 265 207 258 517 378 528 481 365 345 470 194 344 170 405 525 3...

output:

831347350
750043127
416253327
263766726
779499159
956694530
917804288
343381801
114901166
623343225
906670723
778690591
316417113
492815673
171001927
104362383
939654646
276932745
818595772
578133307
985317057
821690134
502407896
945233833
416101283
104397777
692690294
126144492
295378457
306658878
...

result:

ok 301 numbers

Test #183:

score: 17
Accepted
time: 16ms
memory: 101784kb

input:

300
333 443 292 512 254 405 180 516 57 594 495 515 217 467 315 445 207 432 568 506 591 42 475 113 142 139 265 364 185 518 49 375 271 97 447 599 270 464 415 24 535 483 294 227 50 79 373 359 168 311 439 194 388 404 491 517 391 324 558 206 429 161 278 444 191 584 440 296 531 379 567 81 89 14 208 557 6 ...

output:

661219745
163059567
2198108
326776398
525187136
922243785
17024901
517174564
142263621
420155277
353172805
832385614
977883669
857741296
687946729
573593531
840017102
23697728
737429095
472117160
436155190
572135780
680886488
213276085
432605869
763523357
45971716
115233331
754102335
553893171
49771...

result:

ok 301 numbers

Test #184:

score: 17
Accepted
time: 29ms
memory: 101772kb

input:

300
381 428 333 58 19 293 211 556 386 491 227 297 277 158 594 340 55 503 278 586 567 311 582 107 388 138 543 445 173 581 167 305 405 310 69 448 499 318 27 283 542 322 487 497 583 418 115 168 20 415 187 200 118 554 300 414 87 463 326 432 486 198 355 206 14 214 316 384 521 140 212 241 195 248 197 154 ...

output:

179231693
144225054
273769770
461754553
817844531
829326693
862544973
435993633
30838212
425395100
474710556
798926189
582412222
434930434
952161979
274589783
223546632
695833710
139723724
478042085
986523968
620914857
804648766
540485409
526340495
149492272
94266132
357628141
42774126
867498509
950...

result:

ok 301 numbers

Test #185:

score: 17
Accepted
time: 15ms
memory: 101716kb

input:

300
195 118 275 383 450 523 39 211 472 528 448 285 22 355 187 110 257 50 455 6 238 513 199 490 107 119 172 371 498 169 181 590 505 186 30 572 201 141 314 532 445 592 443 436 479 358 548 458 103 570 290 511 336 112 496 361 412 232 426 543 218 357 451 477 397 408 41 581 296 53 489 304 525 529 29 203 2...

output:

271984221
10263004
504466914
650500415
208153390
401115009
15451894
322899233
492854292
587619082
796542561
466907353
939001071
143867372
336829780
290213400
950323119
854538846
878762716
614488123
55127739
121215654
424309610
602480424
483204646
323653661
305013857
171396571
161927099
417493206
181...

result:

ok 301 numbers

Test #186:

score: 17
Accepted
time: 19ms
memory: 101708kb

input:

300
188 143 238 117 234 333 434 259 102 44 111 12 279 495 139 523 560 328 84 230 339 589 147 281 97 480 185 309 469 182 224 561 409 280 167 77 121 408 120 348 5 373 393 308 25 65 398 240 3 553 588 452 539 551 35 29 304 292 390 91 20 372 301 208 596 355 357 104 48 466 170 586 427 293 204 51 135 320 5...

output:

113366380
657518726
378170556
671145229
59006728
688554218
944057555
55555889
558589220
656759394
653434264
981838163
851224125
213963947
955025649
213212989
726315076
135365479
755004802
939027613
820633436
833927668
331710711
708371854
671216885
817327101
282634822
216476168
321009044
501098628
48...

result:

ok 301 numbers

Test #187:

score: 17
Accepted
time: 18ms
memory: 101832kb

input:

300
536 467 73 349 578 509 198 434 93 408 569 589 262 45 149 76 587 483 8 596 537 345 332 42 283 582 523 133 376 174 372 105 173 331 209 102 457 383 403 148 399 290 445 226 237 230 242 233 518 48 224 195 46 253 308 6 588 135 258 310 153 309 1 63 122 64 547 203 414 74 199 575 507 521 218 15 292 503 5...

output:

662273275
8746250
425472026
563910747
874225353
545389908
96473479
56400107
776459648
305607521
575245262
677214709
914595871
635488583
224995812
621297270
980819421
383190342
979391118
539090685
350296774
57426928
342890044
156772541
430255417
954358487
578218028
527017603
951478997
677060715
83975...

result:

ok 301 numbers

Test #188:

score: 17
Accepted
time: 15ms
memory: 101764kb

input:

300
244 589 219 421 157 255 519 268 433 540 359 446 384 205 329 528 327 588 424 387 328 136 386 241 152 371 305 418 220 246 558 237 417 544 381 87 523 462 75 49 579 240 594 263 402 330 382 458 271 284 574 10 335 108 445 30 337 234 17 297 354 295 320 86 575 9 306 525 147 472 362 535 475 85 580 69 185...

output:

275849471
614664523
753134726
549878148
658900970
303032855
767537728
748196087
261503173
727819476
71368708
983307410
835590275
832885905
581949737
33721704
16832325
334531760
793274386
716546347
640001341
641312004
126200887
26936793
578792621
205163828
767156422
820802467
802538218
513787050
2028...

result:

ok 301 numbers

Test #189:

score: 17
Accepted
time: 19ms
memory: 101764kb

input:

300
83 117 231 19 520 434 360 301 101 220 333 251 63 570 551 97 21 191 498 463 454 45 588 548 243 201 306 332 314 155 568 407 537 204 486 114 373 478 22 349 419 235 556 334 137 337 497 594 541 194 378 190 456 139 141 193 371 302 527 78 470 489 321 125 491 555 445 216 547 115 546 308 383 443 330 18 2...

output:

234093546
791520711
6110949
691734828
656322226
974101714
369756785
824429568
786622490
647677106
767449514
539066955
892210252
363894438
688824354
366802311
374768198
447196415
983059600
845201186
449225498
422358406
36825289
808943021
321621751
105116061
955330661
626269574
834808852
259061040
426...

result:

ok 301 numbers

Test #190:

score: 17
Accepted
time: 11ms
memory: 101688kb

input:

300
221 346 326 5 189 145 134 315 473 317 320 131 12 492 335 502 416 304 532 393 526 410 560 251 210 266 99 161 577 125 178 429 309 27 150 264 541 78 381 24 79 439 347 217 88 184 586 389 484 402 154 26 67 530 297 581 53 62 63 559 357 424 223 81 303 338 233 576 386 271 239 579 361 520 294 564 490 28 ...

output:

822056920
736405890
658197001
5337852
504124230
709878109
933428078
429625238
838052775
540481409
195673231
621234121
422657960
884032766
478453596
520833854
173104908
442445665
230265371
83780765
302075263
174520745
16170343
735224259
2354721
220444467
412824523
552565762
90193722
980691383
7160202...

result:

ok 301 numbers

Subtask #8:

score: 0
Skipped

Dependency #1:

0%