Submission #1091567

#TimeUsernameProblemLanguageResultExecution timeMemory
1091567Has2008Bouquet (EGOI24_bouquet)C++17
24 / 100
30 ms18424 KiB
#include "bits/stdc++.h" using namespace std; #define int long long #define endl '\n' const int mod = 1e9 + 7; const int maxn = 1e6 + 5; int n, l[maxn], r[maxn]; int dp[maxn]; int rec(int i) { if (i < 0) return 0; if (dp[i] != -1) return dp[i]; int ret = max(rec(i - 1), rec(i - l[i] - 1) + 1); return dp[i] = ret; } void s1() { cout << (n - 1) / (l[0] + 1) + 1 << endl; } void s2() { memset(dp, -1, sizeof dp); cout << rec(n - 1) << endl; } void solve() { cin >> n; bool flag = 1, flag2 = 1; for(int i = 0; i < n; i++) { cin >> l[i] >> r[i]; if((l[i] != r[i]) || (i & (l[i] != l[i - 1]))) flag = 0; if(r[i] != 0) flag2 = 0; } if(flag) s1(); else if(flag2) s2(); } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int tt = 1; //cin >> tt; while(tt--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...