제출 #1167153

#제출 시각아이디문제언어결과실행 시간메모리
1167153tsengangBouquet (EGOI24_bouquet)C++20
44 / 100
3094 ms6616 KiB
#include <bits/stdc++.h> #define ll long long #define ff first #define ss second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define pb push_back #define ertunt return #define vodka void #define sleepearly ertunt using namespace std; int main() { ll n; cin >> n; vector<ll> l(n),r(n); for(ll i = 0; i < n; i++)cin >> l[i] >> r[i]; vector<ll>d = r; sort(all(d)); if(d[d.size() - 1] == 0){ ll lst = -1; ll ans = 0; for(ll i = 0; i < n; i++){ if(lst == -1){ ans ++; lst = i; continue; } if(l[i] < i-lst){ lst = i; ans++; } } cout << ans << '\n'; ertunt 0; } vector<ll>dp(n+5,1); for(ll i = 0; i < n; i++){ for(ll j = 0; j < i-l[i]; j++){ if(i-j > r[j])dp[i] = max(dp[j]+1,dp[i]); } } cout << *max_element(all(dp)); }
#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...