답안 #23567

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
23567 2017-05-12T16:17:08 Z repeating Boat (APIO16_boat) C++11
0 / 100
1693 ms 524288 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define pll pair<ll,ll>
#define SF(x) scanf("%I64d",&x)

using namespace std;
const long long INF = 2e9;
long long MOD = 1e9+7;
ll n;
ll a[555];
ll b[555];
map<ll,ll>dp[555];
ll DP(ll x,ll last){
    if(x==n)R 1;
    if(last>b[x])R DP(x+1,last);
    ll p=DP(x+1,last);
    last=max(last,a[x]);
    ll &ret=dp[x][last];
    if(ret)R ret-1;
    ret=DP(x,last+1)+p;
    ret%=MOD;
//    cout<<x<<" "<<last<<" "<<ret<<endl;
    ret++;
    R ret-1;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    cout<<DP(0,1)-1;
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2056 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2056 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Memory limit exceeded 1693 ms 524288 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2056 KB Output isn't correct
2 Halted 0 ms 0 KB -