답안 #61203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61203 2018-07-25T11:07:35 Z istlemin Boat (APIO16_boat) C++14
9 / 100
2000 ms 525312 KB
#include<bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

ll mod = 1e9+7;

vi posLast;
vi posLastStart;
vi a;
vi b;
ll n;

vector<vi> mem;

ll getNum(ll lastI,ll index){
	if(index==n) return 1;
	if(mem[lastI][index]!=-1) return mem[lastI][index];
	ll last = posLast[lastI];
	ll ans = getNum(lastI,index+1)%mod;
	rep(i,max(last+1,a[index]),b[index]+1){
        ans = (ans + getNum(posLastStart[index]+i-a[index],index+1))%mod;
	}
    return  mem[lastI][index] = (ans%mod);
}

int main(){
	cin.sync_with_stdio(false);
    cin>>n;
    a.resize(n);
    b.resize(n);
    posLastStart.resize(n);
    posLast.push_back(-1);
    rep(i,0,n) {
		cin>>a[i]>>b[i];
		posLastStart[i] = posLast.size();
		rep(j,a[i],b[i]+1) posLast.push_back(j);
	}

	mem.resize(posLastStart.size()+1,vi(n+1,-1));
    cout<<(getNum(0,0)+mod-1)%mod<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 2424 KB Output is correct
2 Correct 13 ms 2536 KB Output is correct
3 Correct 12 ms 2620 KB Output is correct
4 Correct 11 ms 2628 KB Output is correct
5 Correct 13 ms 2628 KB Output is correct
6 Correct 13 ms 2628 KB Output is correct
7 Correct 14 ms 2628 KB Output is correct
8 Correct 14 ms 2628 KB Output is correct
9 Correct 13 ms 2628 KB Output is correct
10 Correct 17 ms 2628 KB Output is correct
11 Correct 12 ms 2628 KB Output is correct
12 Correct 13 ms 2644 KB Output is correct
13 Correct 13 ms 2644 KB Output is correct
14 Correct 12 ms 2644 KB Output is correct
15 Correct 15 ms 2660 KB Output is correct
16 Correct 12 ms 2660 KB Output is correct
17 Correct 12 ms 2660 KB Output is correct
18 Correct 12 ms 2660 KB Output is correct
19 Correct 12 ms 2660 KB Output is correct
20 Correct 13 ms 2660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 2424 KB Output is correct
2 Correct 13 ms 2536 KB Output is correct
3 Correct 12 ms 2620 KB Output is correct
4 Correct 11 ms 2628 KB Output is correct
5 Correct 13 ms 2628 KB Output is correct
6 Correct 13 ms 2628 KB Output is correct
7 Correct 14 ms 2628 KB Output is correct
8 Correct 14 ms 2628 KB Output is correct
9 Correct 13 ms 2628 KB Output is correct
10 Correct 17 ms 2628 KB Output is correct
11 Correct 12 ms 2628 KB Output is correct
12 Correct 13 ms 2644 KB Output is correct
13 Correct 13 ms 2644 KB Output is correct
14 Correct 12 ms 2644 KB Output is correct
15 Correct 15 ms 2660 KB Output is correct
16 Correct 12 ms 2660 KB Output is correct
17 Correct 12 ms 2660 KB Output is correct
18 Correct 12 ms 2660 KB Output is correct
19 Correct 12 ms 2660 KB Output is correct
20 Correct 13 ms 2660 KB Output is correct
21 Runtime error 30 ms 18512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2056 ms 525312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 2424 KB Output is correct
2 Correct 13 ms 2536 KB Output is correct
3 Correct 12 ms 2620 KB Output is correct
4 Correct 11 ms 2628 KB Output is correct
5 Correct 13 ms 2628 KB Output is correct
6 Correct 13 ms 2628 KB Output is correct
7 Correct 14 ms 2628 KB Output is correct
8 Correct 14 ms 2628 KB Output is correct
9 Correct 13 ms 2628 KB Output is correct
10 Correct 17 ms 2628 KB Output is correct
11 Correct 12 ms 2628 KB Output is correct
12 Correct 13 ms 2644 KB Output is correct
13 Correct 13 ms 2644 KB Output is correct
14 Correct 12 ms 2644 KB Output is correct
15 Correct 15 ms 2660 KB Output is correct
16 Correct 12 ms 2660 KB Output is correct
17 Correct 12 ms 2660 KB Output is correct
18 Correct 12 ms 2660 KB Output is correct
19 Correct 12 ms 2660 KB Output is correct
20 Correct 13 ms 2660 KB Output is correct
21 Runtime error 30 ms 18512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Halted 0 ms 0 KB -