답안 #203906

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
203906 2020-02-23T01:05:34 Z Segtree Boat (APIO16_boat) C++14
31 / 100
1443 ms 524292 KB
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 510
#define X 1000010
vector<ll> dp[N];
ll a[N],b[N];
int main(){
	ll n; cin>>n;
	a[0]=b[0]=0;
	dp[0].push_back(1);
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		for(int j=a[i];j<=b[i];j++)dp[i].push_back(0);
		for(int j=0;j<i;j++){
			for(int k=a[j];k<=b[j];k++){
				if(k<a[i])mad(dp[i][0],dp[j][k-a[j]]);
				else if(k<b[i])mad(dp[i][k+1-a[i]],dp[j][k-a[j]]);
			}
		}
		for(int j=a[i]+1;j<=b[i];j++)mad(dp[i][j-a[i]],dp[i][j-1-a[i]]);
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		for(int j=a[i];j<=b[i];j++){
			//cout<<i<<" "<<j<<" "<<dp[i][j-a[i]]<<endl;
			mad(ans,dp[i][j-a[i]]);
		}
	}
	cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
16 Correct 7 ms 376 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
19 Correct 6 ms 376 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
16 Correct 7 ms 376 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
19 Correct 6 ms 376 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
21 Correct 995 ms 8944 KB Output is correct
22 Correct 964 ms 9080 KB Output is correct
23 Correct 911 ms 8544 KB Output is correct
24 Correct 991 ms 9136 KB Output is correct
25 Correct 1072 ms 9464 KB Output is correct
26 Correct 1443 ms 8360 KB Output is correct
27 Correct 1420 ms 8440 KB Output is correct
28 Correct 1433 ms 8440 KB Output is correct
29 Correct 1437 ms 8520 KB Output is correct
30 Correct 1218 ms 10176 KB Output is correct
31 Correct 1227 ms 10356 KB Output is correct
32 Correct 1276 ms 10060 KB Output is correct
33 Correct 1249 ms 9652 KB Output is correct
34 Correct 1269 ms 10084 KB Output is correct
35 Correct 755 ms 9588 KB Output is correct
36 Correct 745 ms 9860 KB Output is correct
37 Correct 773 ms 9812 KB Output is correct
38 Correct 815 ms 9764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 615 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
16 Correct 7 ms 376 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
19 Correct 6 ms 376 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
21 Correct 995 ms 8944 KB Output is correct
22 Correct 964 ms 9080 KB Output is correct
23 Correct 911 ms 8544 KB Output is correct
24 Correct 991 ms 9136 KB Output is correct
25 Correct 1072 ms 9464 KB Output is correct
26 Correct 1443 ms 8360 KB Output is correct
27 Correct 1420 ms 8440 KB Output is correct
28 Correct 1433 ms 8440 KB Output is correct
29 Correct 1437 ms 8520 KB Output is correct
30 Correct 1218 ms 10176 KB Output is correct
31 Correct 1227 ms 10356 KB Output is correct
32 Correct 1276 ms 10060 KB Output is correct
33 Correct 1249 ms 9652 KB Output is correct
34 Correct 1269 ms 10084 KB Output is correct
35 Correct 755 ms 9588 KB Output is correct
36 Correct 745 ms 9860 KB Output is correct
37 Correct 773 ms 9812 KB Output is correct
38 Correct 815 ms 9764 KB Output is correct
39 Runtime error 615 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
40 Halted 0 ms 0 KB -