# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1248059 | mosesmayer | Bouquet (EGOI24_bouquet) | C++20 | 3095 ms | 2356 KiB |
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;
template<class T> inline T re(){
T N = 0; char c = getchar(); bool neg = 0;
for (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';
for (; c >= '0' && c <= '9'; c = getchar())
N = (N<<3)+(N<<1) + c - '0';
return neg ? -N : N;
}
const int MX = 2e5;
int n;
int l[MX + 5], r[MX + 5];
int dp[MX + 5];
int main() {
n = re<int>();
for (int i = 1; i <= n; i++) {
l[i] = re<int>(); r[i] = re<int>();
}
dp[0] = 0;
int mx = 0;
for (int i = 1; i <= n; i++) {
dp[i] = 1;
for (int j = i - l[i] - 1; j > 0; --j) {
if (j + r[j] < i) dp[i] = max(dp[i], dp[j] + 1);
}
mx = max(mx, dp[i]);
}
printf("%lld\n", mx);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |