Submission #1091307

# Submission time Handle Problem Language Result Execution time Memory
1091307 2024-09-20T13:05:15 Z kasdo Bouquet (EGOI24_bouquet) C++14
8 / 100
582 ms 1048576 KB
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
#define speed cin.tie (0) -> sync_with_stdio (0);ios_base::sync_with_stdio(false);cin.tie(0);
const int maxn = 200005;
int n;
int l[maxn], r[maxn];
int dp[maxn];
int rec(int i)
{
    if (i <= 0) return 0;
    if (dp[i] != -1) return dp[i];
    
    return dp[i] = max(rec(i - 1), rec(i - l[i]) + 1);
}
void s1()
{
    memset(dp, -1, sizeof dp);
    cout<<rec(n)<<endl;
}
void s2()
{
    cout<<(n - 1) / (l[1] + 1) + 1<<endl;
}
void solve()
{
    bool ok = 1;
    cin>>n;
    
    for(int i=1; i<=n; i++) cin>>l[i];
    for(int i=1; i<=n; i++)
    {
        cin>>r[i];
        ok &= (l[i] == r[i]); ok &= (l[i] == l[1]);
    }
    
    if (ok) s2();
    else s1();
}
signed main ()
{
    speed
    // freopen("feast.in", "r", stdin);
    // freopen("feast.out", "w", stdout);
    
    int _ = 1;
    // cin>>_;

    while(_--) solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 13 ms 3492 KB Output is correct
3 Correct 14 ms 3436 KB Output is correct
4 Correct 14 ms 3464 KB Output is correct
5 Correct 15 ms 3416 KB Output is correct
6 Correct 16 ms 3420 KB Output is correct
7 Correct 19 ms 3468 KB Output is correct
8 Correct 30 ms 3412 KB Output is correct
9 Correct 19 ms 3420 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 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
# Verdict Execution time Memory Grader output
1 Correct 13 ms 3416 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 1884 KB Output is correct
4 Runtime error 582 ms 1048576 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 Runtime error 486 ms 1048576 KB Execution killed with signal 9
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 3672 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 533 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 13 ms 3492 KB Output is correct
3 Correct 14 ms 3436 KB Output is correct
4 Correct 14 ms 3464 KB Output is correct
5 Correct 15 ms 3416 KB Output is correct
6 Correct 16 ms 3420 KB Output is correct
7 Correct 19 ms 3468 KB Output is correct
8 Correct 30 ms 3412 KB Output is correct
9 Correct 19 ms 3420 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 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 13 ms 3416 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 1884 KB Output is correct
19 Runtime error 582 ms 1048576 KB Execution killed with signal 9
20 Halted 0 ms 0 KB -