Submission #401485

# Submission time Handle Problem Language Result Execution time Memory
401485 2021-05-10T11:39:23 Z BERNARB01 Boat (APIO16_boat) C++17
0 / 100
4 ms 2252 KB
#include <bits/stdc++.h>

using namespace std;

const int mod = (int) 1e9 + 7;
const int N = 500;

int n, a[N], b[N], rel[N];
long long dp[N][N];

long long sol(int i, int hi) {
	if (i == n) {
		return (hi > 0);
	}
	long long& ret = dp[i][hi];
	if (ret != -1) {
		return ret;
	}
	ret = sol(i + 1, hi);
	if (a[i] > hi) {
		ret += sol(i + 1, a[i]);
		ret %= mod;
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	memset(dp, -1, sizeof dp);
	cin >> n;
	vector<int> se(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		se[i] = a[i];
	}
	sort(se.begin(), se.end());
	map<int, int> mp;
	int idd = 1;
	for (int i = 0; i < n; i++) {
		if (i == 0 || se[i] != se[i - 1]) {
			rel[idd] = se[i];
			mp[se[i]] = idd++;
		}
	}
	for (int i = 0; i < n; i++) {
		a[i] = mp[a[i]];
	}
	cout << sol(0, 0) << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2252 KB Output isn't correct
2 Halted 0 ms 0 KB -