이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
const ll N = 1e6+5 , K = 55 , INF = 1e18 , MOD = 1e9+7 ;
ll dp[N][2*K];
ll n;
vector<pair<ll,ll>> a(N);
ll go(ll i , ll preval){
if(i == n+1) return 0;
if(dp[i][preval] != -1) return dp[i][preval];
ll ans = 0;
for(ll val = a[i].first; val <= a[i].second; val++) if(preval == K || val >= preval) ans = max(ans,1+go(i+1,val));
return dp[i][preval] = ans;
}
void solve(){
cin >> n;
for(ll i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;
memset(dp,-1,sizeof dp);
ll ans = -INF;
for(ll i = 1; i <= n; i++) ans = max(ans,go(i,K));
cout << ans;
}
int main(){
fast;
ll tc = 1;
// cin >> tc;
while(tc--) solve();
return 0;
}
# | 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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |