Submission #1091370

# Submission time Handle Problem Language Result Execution time Memory
1091370 2024-09-20T18:02:30 Z guymmk Bouquet (EGOI24_bouquet) C++14
24 / 100
21 ms 8552 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("popcnt")

//#define int long long
#define ll long long
#define ld long double
#define endl '\n'
#define pii pair<int,int>
#define debug(...) printf(__VA_ARGS__)
//#define debug(...)
#define trace(x) cout<<#x<<"="<<x<<endl;
//#define trace(x)
#define vi vector<int>
#define popcnt(x) (int)__builtin_popcount(x)
#define vpii vector<pii >
#define vvi vector<vector<int> >
#define umap unordered_map
#define uset unordered_set
#define mk make_pair
#define pb push_back
#define pob pop_back
#define _ <<' '<<
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define read(x) for (auto& zu: (x)) cin >> zu;
#define write(x) for (auto& zu: (x))cout << zu<<' '; cout<<endl;
static inline void print(const int &x) {
    if (x > 9)print(x / 10);
    putchar('0' + x % 10);
}

#define F first
#define S second
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define mustawa ios::sync_with_stdio(false);cin.tie(nullptr);
#define mishari main
const int inf=1e9+7;
void fa(bool ok){ cout << (ok ? "YES": "NO") << endl;}
int pw(ll a, ll b, ll mod= 1e9 + 7){
    ll result = 1;
    while(b) {
        if(b&1) {
            result = (result*a)%mod;
        }
        a = (a * a) % mod;
        b>>=1;
    }
    return result;
}
inline void usaco(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}int gcd(int a,int b){
    if (b == 0)return a;
    return gcd(b, a % b);
}

int lcm(int a, int b){
    return (a / gcd(a, b)) * b;
}
//long double log(int base,int x){
//    return log2(x)/log(base);
//}
int log(int base,int x){
    return (int)(log2(x)/log(base));
}
void vod(){}
int sum(int l,int r){
    if(l>r)swap(l,r);
    int a=((l-1)*(l))/2;
    int b=(r*(r+1))/2;
    return b-a;
}
int L[(int)2e5+5],R[(int)(2e5+5)],dp[(int)2e5+5],n;
int r0(int i){
    if(i<0)return 0;
    if(dp[i]!=-1)return dp[i];
    return dp[i]=max(r0(i-1),r0(i-L[i]-1)+1);
}
void solve(){memset(dp,-1,sizeof dp);
    cin>>n;
    bool b=0;
    for(int i=0;i<n;i++){
        cin>>L[i]>>R[i];
        if(L[i]!=R[i])b=1;
        if(i&&L[i]!=L[i-1])b=1;
    }if(n<=1000){
        for(int i=0;i<n;i++){
            dp[i]=1;
            for(int j=0;j<i-L[i];j++){
                if(j+R[i]<i)dp[i]=max(dp[i],dp[j]+1);
            }
        }return cout<<*max_element((dp),dp+(int)2e5+5)<<endl,vod();
    }
    if(!b)return cout<<(n-1)/(L[0]+1)+1<<endl,vod();
    else {

        cout<<r0(n-1)<<endl;
    }
}
signed mishari() {
    mustawa;
    //usaco("nocross");
    int tescases = 1;
    //cin>>tescases;
    for (int i = 1; i <= tescases; i++) {
        //cout<<"Case "<<i<<":"<<endl;
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 13 ms 2592 KB Output is correct
3 Correct 15 ms 2652 KB Output is correct
4 Correct 13 ms 2620 KB Output is correct
5 Correct 15 ms 2652 KB Output is correct
6 Correct 16 ms 2684 KB Output is correct
7 Correct 19 ms 2680 KB Output is correct
8 Correct 20 ms 2652 KB Output is correct
9 Correct 19 ms 2668 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1240 KB Output is correct
15 Correct 1 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2800 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 18 ms 8024 KB Output is correct
5 Correct 18 ms 6492 KB Output is correct
6 Correct 16 ms 5884 KB Output is correct
7 Correct 17 ms 5212 KB Output is correct
8 Correct 16 ms 4956 KB Output is correct
9 Correct 15 ms 4188 KB Output is correct
10 Correct 17 ms 4008 KB Output is correct
11 Correct 16 ms 3164 KB Output is correct
12 Correct 16 ms 3244 KB Output is correct
13 Correct 15 ms 2904 KB Output is correct
14 Correct 15 ms 2852 KB Output is correct
15 Correct 16 ms 2752 KB Output is correct
16 Correct 15 ms 2904 KB Output is correct
17 Correct 15 ms 2652 KB Output is correct
18 Correct 15 ms 2644 KB Output is correct
19 Correct 16 ms 2648 KB Output is correct
20 Correct 16 ms 2648 KB Output is correct
21 Correct 16 ms 2652 KB Output is correct
22 Correct 18 ms 2668 KB Output is correct
23 Correct 19 ms 2700 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 1 ms 1116 KB Output is correct
27 Correct 1 ms 1116 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 1 ms 1116 KB Output is correct
30 Correct 19 ms 7260 KB Output is correct
31 Correct 19 ms 8552 KB Output is correct
32 Correct 1 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1112 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Incorrect 1 ms 1268 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2648 KB Output is correct
2 Correct 1 ms 1256 KB Output is correct
3 Correct 18 ms 7768 KB Output is correct
4 Correct 17 ms 6492 KB Output is correct
5 Correct 17 ms 6664 KB Output is correct
6 Correct 21 ms 7772 KB Output is correct
7 Incorrect 18 ms 6492 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 13 ms 2592 KB Output is correct
3 Correct 15 ms 2652 KB Output is correct
4 Correct 13 ms 2620 KB Output is correct
5 Correct 15 ms 2652 KB Output is correct
6 Correct 16 ms 2684 KB Output is correct
7 Correct 19 ms 2680 KB Output is correct
8 Correct 20 ms 2652 KB Output is correct
9 Correct 19 ms 2668 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1240 KB Output is correct
15 Correct 1 ms 1112 KB Output is correct
16 Correct 13 ms 2800 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 18 ms 8024 KB Output is correct
20 Correct 18 ms 6492 KB Output is correct
21 Correct 16 ms 5884 KB Output is correct
22 Correct 17 ms 5212 KB Output is correct
23 Correct 16 ms 4956 KB Output is correct
24 Correct 15 ms 4188 KB Output is correct
25 Correct 17 ms 4008 KB Output is correct
26 Correct 16 ms 3164 KB Output is correct
27 Correct 16 ms 3244 KB Output is correct
28 Correct 15 ms 2904 KB Output is correct
29 Correct 15 ms 2852 KB Output is correct
30 Correct 16 ms 2752 KB Output is correct
31 Correct 15 ms 2904 KB Output is correct
32 Correct 15 ms 2652 KB Output is correct
33 Correct 15 ms 2644 KB Output is correct
34 Correct 16 ms 2648 KB Output is correct
35 Correct 16 ms 2648 KB Output is correct
36 Correct 16 ms 2652 KB Output is correct
37 Correct 18 ms 2668 KB Output is correct
38 Correct 19 ms 2700 KB Output is correct
39 Correct 1 ms 1116 KB Output is correct
40 Correct 1 ms 1116 KB Output is correct
41 Correct 1 ms 1116 KB Output is correct
42 Correct 1 ms 1116 KB Output is correct
43 Correct 1 ms 1116 KB Output is correct
44 Correct 1 ms 1116 KB Output is correct
45 Correct 19 ms 7260 KB Output is correct
46 Correct 19 ms 8552 KB Output is correct
47 Correct 1 ms 1116 KB Output is correct
48 Correct 1 ms 1116 KB Output is correct
49 Correct 1 ms 1116 KB Output is correct
50 Correct 1 ms 1112 KB Output is correct
51 Correct 1 ms 1116 KB Output is correct
52 Correct 1 ms 1116 KB Output is correct
53 Correct 1 ms 1116 KB Output is correct
54 Correct 1 ms 1116 KB Output is correct
55 Correct 1 ms 1112 KB Output is correct
56 Correct 1 ms 1116 KB Output is correct
57 Correct 1 ms 1116 KB Output is correct
58 Correct 1 ms 1116 KB Output is correct
59 Incorrect 1 ms 1268 KB Output isn't correct
60 Halted 0 ms 0 KB -