Submission #1037197

# Submission time Handle Problem Language Result Execution time Memory
1037197 2024-07-28T10:27:23 Z Halym2007 Boat (APIO16_boat) C++17
0 / 100
1499 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 5;
#define ll long long
ll a[N], b[N];
int dp[N], mod = 1e9 + 7, n;
map <ll, int> m;
int main () {
//	freopen ("input.txt", "r", stdin);
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i] >> b[i];
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = a[i]; j <= b[i]; ++j) {
			m[j] = 1;
		}
	}
	int san = 0;
	for (auto i : m) {
		m[i.first] = ++san;
	}
	for (int i = 1; i <= n; ++i) {
		a[i] = m[a[i]]; b[i] = m[b[i]];
	}
	dp[0] = 1;
	for (int i = 1; i <= n; ++i) {
//		if (i == 2) {
//			return cout << dp[2], 0;
//		}
		for (int j = b[i]; j >= a[i]; j--) {
			int sum = 0;
			for (int l = 0; l < j; ++l) {
				sum += dp[l];
				sum %= mod;
			}
			dp[j] += sum;
			dp[j] %= mod;
		}
	}
	int jog = 0;
	for (int i = 1; i <= san; ++i) {
		jog += dp[i];
//		cout << i << " " << dp[i] << "\n";
	}
	cout << jog;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1499 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -