# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
991341 |
2024-06-02T06:58:29 Z |
Andrey |
Trains (BOI24_trains) |
C++14 |
|
111 ms |
317012 KB |
#include<bits/stdc++.h>
using namespace std;
long long bruh[100001][400];
const long long MOD = 1e9+7;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n,a,b;
cin >> n;
vector<pair<long long,long long>> haha(n+1);
for(long long i = 0; i < n; i++) {
cin >> a >> b;
haha[i] = {a,b};
}
reverse(haha.begin(),haha.end());
vector<long long> dp(n+1,1);
dp[0] = 0;
for(long long i = 0; i < 400; i++) {
bruh[0][i] = 0;
}
for(long long i = 1; i <= n; i++) {
a = haha[i].first;
b = haha[i].second;
if(a*a <= n) {
if(i > a) {
dp[i]+=bruh[i-a][a];
dp[i]%=MOD;
}
if(i > a*(b+1)) {
dp[i]-=bruh[i-a*(b+1)][a];
dp[i]+=MOD;
dp[i]%=MOD;
}
}
else {
for(long long j = i-a; j >= max(0LL,j-a*b); j-=a) {
dp[i]+=dp[j];
dp[i]%=MOD;
}
}
for(long long j = 1; j*j <= n; j++) {
if(j <= i) {
bruh[i][j] = (bruh[i-j][j]+dp[i])%MOD;
}
else {
bruh[i][j] = dp[i];
}
}
}
cout << dp[n];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
460 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
460 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
7 ms |
27480 KB |
Output is correct |
21 |
Incorrect |
2 ms |
10844 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
5 ms |
21084 KB |
Output is correct |
3 |
Correct |
3 ms |
14940 KB |
Output is correct |
4 |
Correct |
5 ms |
27484 KB |
Output is correct |
5 |
Correct |
66 ms |
244396 KB |
Output is correct |
6 |
Correct |
90 ms |
315732 KB |
Output is correct |
7 |
Correct |
91 ms |
315728 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
7 ms |
33628 KB |
Output is correct |
12 |
Correct |
111 ms |
315880 KB |
Output is correct |
13 |
Correct |
1 ms |
512 KB |
Output is correct |
14 |
Correct |
6 ms |
33628 KB |
Output is correct |
15 |
Correct |
90 ms |
315768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
153444 KB |
Output is correct |
2 |
Correct |
29 ms |
127068 KB |
Output is correct |
3 |
Correct |
89 ms |
317012 KB |
Output is correct |
4 |
Correct |
65 ms |
228692 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
6 ms |
33628 KB |
Output is correct |
8 |
Correct |
93 ms |
316940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
460 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
7 ms |
27480 KB |
Output is correct |
21 |
Incorrect |
2 ms |
10844 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |