답안 #388952

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
388952 2021-04-13T11:16:52 Z prvocislo Boat (APIO16_boat) C++17
9 / 100
7 ms 4340 KB
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
typedef long long ll;
using namespace std;

const ll mod = 1e9 + 7;
void upd(ll& a, const ll& b) { a = (a + b) % mod; }
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n + 1), b(n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
	set<int>s(a.begin(), a.end());
	for (int i = 0; i <= n; i++) s.insert(b[i] + 1);
	vector<int> v(s.begin(), s.end());
	vector<vector<ll> > dp(n + 1, vector<ll>(v.size(), 0));
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		dp[i] = dp[i - 1];
		ll sum = 0;
		for (int j = 0; j < v.size() - 1; j++)
		{
			if (a[i] <= v[j] && v[j] <= b[i])
			{
				upd(dp[i][j], (sum * 1ll * (v[j + 1] - v[j])) % mod);
			}
			upd(sum, dp[i - 1][j]);
		}
	}
	ll ans = 0;
	for (int j = 1; j < v.size(); j++) upd(ans, dp[n][j]);
	cout << ans << "\n";
	return 0;
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:31:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for (int j = 0; j < v.size() - 1; j++)
      |                   ~~^~~~~~~~~~~~~~
boat.cpp:41:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for (int j = 1; j < v.size(); j++) upd(ans, dp[n][j]);
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4300 KB Output is correct
2 Correct 6 ms 4300 KB Output is correct
3 Correct 5 ms 4300 KB Output is correct
4 Correct 5 ms 4300 KB Output is correct
5 Correct 5 ms 4300 KB Output is correct
6 Correct 6 ms 4300 KB Output is correct
7 Correct 7 ms 4300 KB Output is correct
8 Correct 5 ms 4300 KB Output is correct
9 Correct 5 ms 4300 KB Output is correct
10 Correct 7 ms 4300 KB Output is correct
11 Correct 5 ms 4300 KB Output is correct
12 Correct 5 ms 4288 KB Output is correct
13 Correct 5 ms 4340 KB Output is correct
14 Correct 5 ms 4300 KB Output is correct
15 Correct 6 ms 4340 KB Output is correct
16 Correct 2 ms 972 KB Output is correct
17 Correct 2 ms 1100 KB Output is correct
18 Correct 2 ms 1092 KB Output is correct
19 Correct 2 ms 1100 KB Output is correct
20 Correct 2 ms 972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4300 KB Output is correct
2 Correct 6 ms 4300 KB Output is correct
3 Correct 5 ms 4300 KB Output is correct
4 Correct 5 ms 4300 KB Output is correct
5 Correct 5 ms 4300 KB Output is correct
6 Correct 6 ms 4300 KB Output is correct
7 Correct 7 ms 4300 KB Output is correct
8 Correct 5 ms 4300 KB Output is correct
9 Correct 5 ms 4300 KB Output is correct
10 Correct 7 ms 4300 KB Output is correct
11 Correct 5 ms 4300 KB Output is correct
12 Correct 5 ms 4288 KB Output is correct
13 Correct 5 ms 4340 KB Output is correct
14 Correct 5 ms 4300 KB Output is correct
15 Correct 6 ms 4340 KB Output is correct
16 Correct 2 ms 972 KB Output is correct
17 Correct 2 ms 1100 KB Output is correct
18 Correct 2 ms 1092 KB Output is correct
19 Correct 2 ms 1100 KB Output is correct
20 Correct 2 ms 972 KB Output is correct
21 Incorrect 6 ms 3984 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4300 KB Output is correct
2 Correct 6 ms 4300 KB Output is correct
3 Correct 5 ms 4300 KB Output is correct
4 Correct 5 ms 4300 KB Output is correct
5 Correct 5 ms 4300 KB Output is correct
6 Correct 6 ms 4300 KB Output is correct
7 Correct 7 ms 4300 KB Output is correct
8 Correct 5 ms 4300 KB Output is correct
9 Correct 5 ms 4300 KB Output is correct
10 Correct 7 ms 4300 KB Output is correct
11 Correct 5 ms 4300 KB Output is correct
12 Correct 5 ms 4288 KB Output is correct
13 Correct 5 ms 4340 KB Output is correct
14 Correct 5 ms 4300 KB Output is correct
15 Correct 6 ms 4340 KB Output is correct
16 Correct 2 ms 972 KB Output is correct
17 Correct 2 ms 1100 KB Output is correct
18 Correct 2 ms 1092 KB Output is correct
19 Correct 2 ms 1100 KB Output is correct
20 Correct 2 ms 972 KB Output is correct
21 Incorrect 6 ms 3984 KB Output isn't correct
22 Halted 0 ms 0 KB -