QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#687458 | #6467. Bricks | PetroTarnavskyi# | AC ✓ | 16ms | 19292kb | C++23 | 1.0kb | 2024-10-29 19:08:47 | 2024-10-29 19:08:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;
const int mod = 1e9 + 7;
void updAdd(int& a, int b)
{
a += b;
if(a >= mod)
a -= mod;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
n += 2;
VI a(n);
FOR(i, 0, m)
{
int p;
cin >> p;
a[p]++;
}
VI pref(n + 1);
FOR(i, 0, n)
pref[i + 1] = pref[i] + a[i];
VI dp(n);
dp[0] = 1;
VI vals(m + n + 1);
FOR(j, 0, n)
{
if(j != 0 && a[j] == 0)
dp[j] = vals[pref[j] - j + n];
updAdd(vals[pref[j + 1] - (j + 1) + n], dp[j]);
}
cout << dp[n - 1] << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 16ms
memory: 19240kb
input:
1000000 100000 408324 143131 643851 694890 107359 902536 740575 457980 512490 751132 582372 664028 593265 689656 354062 909500 400398 427138 133001 796585 691941 338615 815678 609465 543837 46433 284437 312712 885702 931622 991085 643614 642120 610782 572305 519633 84497 243754 622392 308276 379654 ...
output:
998609830
result:
ok single line: '998609830'
Test #2:
score: 0
Accepted
time: 6ms
memory: 5164kb
input:
99999 99000 60977 30236 70053 98886 69811 23236 39358 8103 71462 39356 49693 50211 5053 73374 47602 20302 36190 59536 99683 79788 14842 81995 89363 19705 69982 8455 50211 42099 7623 42099 59831 72841 24785 16735 51903 71655 8103 82165 21132 42099 60977 81995 96999 5053 82165 39356 16735 78964 20302 ...
output:
874946883
result:
ok single line: '874946883'
Test #3:
score: 0
Accepted
time: 4ms
memory: 19280kb
input:
1000000 100000 705293 894502 383443 813770 979591 212086 693442 794877 178724 527174 851980 584315 334084 582412 293739 394837 876142 926379 267370 350667 796365 135558 639670 129723 896297 19265 95168 829381 565091 742875 330772 868542 772886 534981 436009 137657 973442 21695 684363 835621 298294 1...
output:
879784590
result:
ok single line: '879784590'
Test #4:
score: 0
Accepted
time: 4ms
memory: 19144kb
input:
1000000 100000 426917 320935 465400 41754 293592 445705 276338 200976 8079 457212 793559 482868 388453 250215 966812 475244 30998 271254 426783 511320 701578 689208 298177 778954 257711 697274 971794 247307 71866 725985 164527 415125 487001 10571 167850 348797 724756 493590 244466 902678 127663 9013...
output:
329311386
result:
ok single line: '329311386'
Test #5:
score: 0
Accepted
time: 8ms
memory: 19276kb
input:
1000000 100000 959793 547685 844132 773126 697683 760415 291904 843900 855190 87056 143630 408100 904438 715653 69409 271763 578991 147462 283413 158158 948837 33335 722259 120061 995672 9133 52854 515718 520662 418242 720796 722259 797475 757743 62257 308167 61273 33780 439385 184681 870888 609572 ...
output:
854849669
result:
ok single line: '854849669'
Test #6:
score: 0
Accepted
time: 4ms
memory: 19292kb
input:
1000000 100000 993106 183477 562544 208234 583361 967153 810565 855522 391331 410550 870317 838336 432620 705273 493803 837522 208234 208234 759289 870317 552983 132686 81364 775479 837522 128429 944363 609013 39828 367454 779195 391331 654622 562544 729910 700750 590324 624237 277483 427961 654622 ...
output:
537760851
result:
ok single line: '537760851'
Test #7:
score: 0
Accepted
time: 8ms
memory: 19232kb
input:
1000000 100000 757947 68300 757947 757947 577471 585574 979918 577471 577471 979918 296644 585574 577471 369105 585574 577471 979918 757947 979918 369105 170090 585574 369105 904694 170090 757947 369105 577471 19409 19409 170090 369105 19409 19409 170090 170090 585574 170090 68300 757947 585574 1700...
output:
449022344
result:
ok single line: '449022344'
Test #8:
score: 0
Accepted
time: 8ms
memory: 6776kb
input:
200000 100000 108977 172940 192199 144664 78209 107164 180013 61245 34598 91184 89592 177723 87843 128308 88815 87504 193145 179444 66097 155864 113564 199307 81305 89351 197574 109583 81503 106378 118707 44852 8553 129717 30035 142770 59515 101178 127554 73119 99538 140431 101863 121550 78543 18427...
output:
239166365
result:
ok single line: '239166365'
Test #9:
score: 0
Accepted
time: 7ms
memory: 6772kb
input:
200000 100000 100547 116726 18819 66958 125736 143700 99710 130284 6321 79965 147641 179138 57369 104074 22307 124225 180925 139230 149065 108769 35567 57369 143650 89048 19363 10914 191890 83309 154813 52276 80501 179951 127741 178296 148287 157293 48499 96632 158960 13707 75220 35191 120761 69597 ...
output:
832637807
result:
ok single line: '832637807'
Test #10:
score: 0
Accepted
time: 7ms
memory: 6892kb
input:
200000 100000 61391 26799 151399 22486 54096 73318 199027 11025 106408 184977 147901 66865 168011 149809 124891 99413 128795 19790 71837 136135 13555 102992 37073 85118 124423 30195 135789 77621 61625 99413 21337 153051 186158 97747 121061 46372 37513 179824 161452 58222 157297 137465 191858 104655 ...
output:
554352280
result:
ok single line: '554352280'
Test #11:
score: 0
Accepted
time: 5ms
memory: 4920kb
input:
100000 80000 63987 28314 70187 19901 67008 88542 73294 67342 23427 94995 73062 28177 36699 54522 96083 22376 89830 53478 50419 90494 90156 38300 3464 11429 86977 83185 94027 67791 8967 55916 77470 51300 31621 32311 24385 7513 1264 34693 76828 96606 15926 91776 60456 78360 45900 69743 65937 79051 183...
output:
605986639
result:
ok single line: '605986639'
Test #12:
score: 0
Accepted
time: 5ms
memory: 5052kb
input:
100000 80000 33137 61359 4632 38229 61186 64112 12478 67490 21074 12350 5202 34282 6289 45615 28922 34142 54099 62215 40720 55660 53204 98602 25013 62051 85844 49014 87048 89485 39840 60391 16174 11069 92620 49236 15004 73363 28781 7657 33230 83983 45877 69825 93769 95564 34966 23985 53440 95658 661...
output:
345278790
result:
ok single line: '345278790'
Test #13:
score: 0
Accepted
time: 5ms
memory: 4896kb
input:
100000 80000 50207 33558 61018 31483 93416 11214 72877 95980 26059 70989 77620 3300 11729 82733 85561 88754 94460 38609 45462 70989 40822 15270 30133 30978 40355 91166 33423 92429 3373 93576 56063 3828 26056 93576 40549 9067 16670 28910 95385 7366 12395 30431 83349 46949 82015 5320 1003 1862 64056 4...
output:
959301216
result:
ok single line: '959301216'
Test #14:
score: 0
Accepted
time: 5ms
memory: 4908kb
input:
100000 80000 49737 23623 50713 91337 89156 16964 75397 85713 6830 60390 71105 50826 5050 29517 47758 31767 5554 51897 28217 51262 48401 59487 80337 18690 27761 88048 29117 77324 44987 3799 78778 5634 33004 70889 60513 23623 23227 96036 39139 37085 10847 99141 34541 76359 81427 5016 73523 95003 18662...
output:
378316516
result:
ok single line: '378316516'
Test #15:
score: 0
Accepted
time: 5ms
memory: 4900kb
input:
100000 80000 46819 26475 60822 6046 14601 633 69544 55449 91030 29152 23404 37707 12744 33941 62294 47543 10954 89981 93952 5875 14601 6647 98243 64242 35394 27005 62294 46384 11918 60822 33942 88767 87537 70785 57669 60189 38275 46819 98243 27005 22046 54283 17781 68281 80952 31400 94470 55895 8321...
output:
783905030
result:
ok single line: '783905030'
Test #16:
score: 0
Accepted
time: 5ms
memory: 4916kb
input:
100000 80000 87550 50573 67769 94385 77905 50573 64192 78449 65396 53877 64192 16096 25224 33126 96158 64192 2556 96172 70059 80929 69799 24480 15201 64909 77905 72732 63652 74928 42796 36213 6063 82346 35433 80361 23523 19849 16863 24480 76897 91085 84369 20341 10797 67161 15201 23433 80929 75575 1...
output:
898012254
result:
ok single line: '898012254'
Test #17:
score: 0
Accepted
time: 5ms
memory: 4896kb
input:
100000 90000 85705 95619 85873 19398 36736 85873 54079 1181 36736 88539 88539 54079 3755 88239 85705 85873 88539 19398 36736 1181 19398 88239 54079 95619 1181 3755 36736 3755 36736 85705 85705 88539 95619 36736 3755 95619 95619 19398 1181 19398 3755 88239 85705 85705 54079 54079 36736 85873 36736 95...
output:
597974851
result:
ok single line: '597974851'
Test #18:
score: 0
Accepted
time: 5ms
memory: 5316kb
input:
100000 90000 21448 62705 62705 62705 62705 62705 62705 62705 62705 21448 62705 62705 21448 62705 62705 21448 62705 62705 21448 62705 21448 21448 62705 21448 62705 21448 62705 62705 62705 62705 62705 21448 21448 62705 62705 62705 21448 62705 62705 21448 62705 21448 62705 62705 21448 21448 62705 21448...
output:
50015001
result:
ok single line: '50015001'
Test #19:
score: 0
Accepted
time: 5ms
memory: 5312kb
input:
100000 90000 3088 3088 19254 19254 3088 19254 3088 19254 12161 12161 19254 19254 19254 3088 19254 19254 19254 19254 12161 19254 3088 3088 3088 3088 19254 3088 12161 19254 12161 12161 12161 12161 3088 19254 3088 19254 12161 3088 19254 19254 3088 3088 3088 3088 19254 3088 3088 19254 3088 3088 12161 30...
output:
3088
result:
ok single line: '3088'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
50 50 5 17 10 49 15 32 48 38 12 10 19 8 23 45 14 39 20 14 5 33 8 45 48 36 6 7 37 37 42 23 4 21 38 1 4 12 28 38 40 37 20 34 46 14 30 24 21 36 13 7
output:
1
result:
ok single line: '1'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
50 30 47 15 41 27 22 47 15 40 45 40 41 15 9 41 27 7 47 15 12 12 47 47 15 9 7 45 45 22 27 22
output:
765
result:
ok single line: '765'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
50 30 8 44 34 20 22 40 8 44 30 40 30 13 13 18 13 20 42 44 44 22 34 20 13 44 44 20 18 8 34 42
output:
2142
result:
ok single line: '2142'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
50 30 35 27 27 4 22 22 4 22 27 35 34 22 12 27 4 13 22 34 46 22 13 13 27 13 35 35 35 12 50 34
output:
930
result:
ok single line: '930'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
50 30 47 25 25 25 25 40 29 21 40 21 41 45 45 29 21 40 40 47 45 41 1 1 25 45 41 41 47 21 45 40
output:
86
result:
ok single line: '86'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
50 30 42 41 30 1 14 42 24 44 41 41 1 41 9 14 24 1 14 24 44 24 14 44 41 24 44 36 9 36 20 24
output:
528
result:
ok single line: '528'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
50 30 15 11 3 7 7 15 41 7 26 19 19 3 15 41 26 3 45 15 26 19 15 19 33 15 26 45 7 45 19 11
output:
1080
result:
ok single line: '1080'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
50 30 47 13 45 47 47 15 15 13 31 11 47 39 47 35 39 31 11 19 47 15 13 15 31 11 39 39 11 15 45 13
output:
330
result:
ok single line: '330'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
50 30 49 9 15 49 49 9 1 1 40 8 1 26 26 8 26 1 9 15 7 9 29 15 32 40 32 1 15 15 15 29
output:
200
result:
ok single line: '200'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
50 30 3 4 38 43 43 41 41 21 3 38 21 38 21 3 3 4 43 3 22 48 20 48 38 4 3 4 20 21 41 48
output:
330
result:
ok single line: '330'
Test #30:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
50 30 1 11 22 25 2 39 34 2 14 46 1 1 14 22 14 2 1 17 2 34 46 1 1 1 39 11 22 14 46 1
output:
36
result:
ok single line: '36'
Test #31:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
50 30 22 34 6 50 6 50 21 18 18 50 26 18 8 6 24 6 26 22 24 24 50 24 24 50 22 21 10 21 24 22
output:
51
result:
ok single line: '51'
Test #32:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
50 30 26 31 37 43 24 35 24 31 28 28 35 26 47 43 28 35 37 47 47 9 26 35 43 37 47 24 35 35 26 28
output:
101
result:
ok single line: '101'