답안 #970611

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970611 2024-04-26T19:27:50 Z starchan Boat (APIO16_boat) C++17
9 / 100
264 ms 41756 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define in array<int, 2>
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)

const int mod = 1e9+7; 
const int MX = 5e3+5;

int dp[MX][2*MX];
int ans[2*MX];

signed main()
{
	fast();
	vector<int> v;
	int n;
	cin >> n;
	n++;
	vector<in> a(n+1);
	for(int i = 1; i < n; i++)
	{
		cin >> a[i][0] >> a[i][1]; 
		v.pb(a[i][0]); v.pb(++a[i][1]);
	}
	a[n][0] = 1e9+1; a[n][1] = 1e9+2;
	v.pb(a[n][0]); v.pb(a[n][1]);
	sort(v.begin(), v.end());
	vector<int> CC; CC.pb(v[0]);
	for(auto x: v)
	{
		if(x != CC.back())
			CC.pb(x);
	}
	for(int i = 1; i <= n; i++)
	{
		a[i][0] = lower_bound(CC.begin(), CC.end(), a[i][0])-CC.begin();
		a[i][1] = lower_bound(CC.begin(), CC.end(), a[i][1])-CC.begin();
	}

	int M = CC.size();
	//We are interested in dp[n][MM]
	for(int i = 1; i <= n; i++)
	{
		for(int j = a[i][0]; j < a[i][1]; j++)
		{
			dp[i][j] = 1;
			for(int d = 0; d < j; d++)
			{
				dp[i][j]+=ans[d];
				dp[i][j]%=mod;
			}
			dp[i][j]*=(CC[j+1]-CC[j]); dp[i][j]%=mod;
		}
		for(int j = a[i][0]; j < a[i][1]; j++)
		{
			ans[j]+=dp[i][j];
			ans[j]%=mod;
		}
	}
	dp[n][M-2]+=(mod-1); dp[n][M-2]%=mod;
	cout << dp[n][M-2] << "\n";
	return 0;
}	
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 41308 KB Output is correct
2 Correct 6 ms 41476 KB Output is correct
3 Correct 6 ms 41544 KB Output is correct
4 Correct 6 ms 41308 KB Output is correct
5 Correct 6 ms 41428 KB Output is correct
6 Correct 6 ms 41304 KB Output is correct
7 Correct 6 ms 41308 KB Output is correct
8 Correct 6 ms 41564 KB Output is correct
9 Correct 5 ms 41308 KB Output is correct
10 Correct 6 ms 41524 KB Output is correct
11 Correct 5 ms 41308 KB Output is correct
12 Correct 6 ms 41496 KB Output is correct
13 Correct 6 ms 41308 KB Output is correct
14 Correct 9 ms 41564 KB Output is correct
15 Correct 6 ms 41308 KB Output is correct
16 Correct 5 ms 41756 KB Output is correct
17 Correct 5 ms 41508 KB Output is correct
18 Correct 5 ms 41464 KB Output is correct
19 Correct 5 ms 41304 KB Output is correct
20 Correct 5 ms 41308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 41308 KB Output is correct
2 Correct 6 ms 41476 KB Output is correct
3 Correct 6 ms 41544 KB Output is correct
4 Correct 6 ms 41308 KB Output is correct
5 Correct 6 ms 41428 KB Output is correct
6 Correct 6 ms 41304 KB Output is correct
7 Correct 6 ms 41308 KB Output is correct
8 Correct 6 ms 41564 KB Output is correct
9 Correct 5 ms 41308 KB Output is correct
10 Correct 6 ms 41524 KB Output is correct
11 Correct 5 ms 41308 KB Output is correct
12 Correct 6 ms 41496 KB Output is correct
13 Correct 6 ms 41308 KB Output is correct
14 Correct 9 ms 41564 KB Output is correct
15 Correct 6 ms 41308 KB Output is correct
16 Correct 5 ms 41756 KB Output is correct
17 Correct 5 ms 41508 KB Output is correct
18 Correct 5 ms 41464 KB Output is correct
19 Correct 5 ms 41304 KB Output is correct
20 Correct 5 ms 41308 KB Output is correct
21 Incorrect 264 ms 41296 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 8536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 41308 KB Output is correct
2 Correct 6 ms 41476 KB Output is correct
3 Correct 6 ms 41544 KB Output is correct
4 Correct 6 ms 41308 KB Output is correct
5 Correct 6 ms 41428 KB Output is correct
6 Correct 6 ms 41304 KB Output is correct
7 Correct 6 ms 41308 KB Output is correct
8 Correct 6 ms 41564 KB Output is correct
9 Correct 5 ms 41308 KB Output is correct
10 Correct 6 ms 41524 KB Output is correct
11 Correct 5 ms 41308 KB Output is correct
12 Correct 6 ms 41496 KB Output is correct
13 Correct 6 ms 41308 KB Output is correct
14 Correct 9 ms 41564 KB Output is correct
15 Correct 6 ms 41308 KB Output is correct
16 Correct 5 ms 41756 KB Output is correct
17 Correct 5 ms 41508 KB Output is correct
18 Correct 5 ms 41464 KB Output is correct
19 Correct 5 ms 41304 KB Output is correct
20 Correct 5 ms 41308 KB Output is correct
21 Incorrect 264 ms 41296 KB Output isn't correct
22 Halted 0 ms 0 KB -