Submission #362526

# Submission time Handle Problem Language Result Execution time Memory
362526 2021-02-03T14:40:40 Z flappybird Boat (APIO16_boat) C++14
9 / 100
2000 ms 524292 KB
#include <bits/stdc++.h>
using namespace std;
#define MAX 510
#define all(v) v.begin(), v.end()
#define ln '\n'
#define MOD 1000000007
#define INF 210000000000
#define pb push_back
#define abs(x) (((x)>0)?(x):(-(x)))
#define len(x) ((x).second-(x).first)
typedef long long ll;
vector<ll> dp[MAX], sum[MAX];
ll A[MAX], B[MAX];
pair<ll, ll> s[MAX];
int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N;
	cin >> N;
	ll i, j, k;
	for (i = 1; i <= N; i++) cin >> A[i] >> B[i], dp[i].pb(0), sum[i].pb(0);
	for (i = A[1]; i <= B[1]; i++) {
		dp[1].pb(1);
		sum[1].pb(0);
		sum[1][i - A[1] + 1] = (sum[1][i - A[1]] + dp[1][i - A[1] + 1]) % MOD;
	}
	s[1] = { A[1], 1 };
	ll it;
	for (i = 2; i <= N; i++) {
		for (j = A[i]; j <= B[i]; j++) {
			dp[i].pb(1), sum[i].pb(0);
			for (it = 1; it <= i - 1; it++) {
				k = s[it].second;
				if (j - A[k] <= 0) break;
				dp[i][j - A[i] + 1] += sum[k][min(j - A[k], (ll)(sum[k].size() - 1))];
				dp[i][j - A[i] + 1] %= MOD;
			}
			sum[i][j - A[i] + 1] = (sum[i][j - A[i]] + dp[i][j - A[i] + 1]) % MOD;
		}
		for (j = 1; j < i; j++) {
			if (s[j].first > A[i]) break;
		}
		pair<ll, ll> tmp = { A[i], i }, t;
		k = j;
		for (j = k; j <= i - 1; j++) {
			t = s[j];
			s[j] = tmp;
			tmp = t;
		}
		s[i] = tmp;
	}
	ll ans = 0;
	for (i = 1; i <= N; i++) ans += sum[i][sum[i].size() - 1];
	ans %= MOD;
	while (ans < 0) ans += MOD;
	cout << ans << ln;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
21 Correct 1870 ms 18028 KB Output is correct
22 Correct 1754 ms 17524 KB Output is correct
23 Correct 1681 ms 17064 KB Output is correct
24 Correct 1827 ms 18136 KB Output is correct
25 Correct 1857 ms 17988 KB Output is correct
26 Execution timed out 2081 ms 14132 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 977 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
21 Correct 1870 ms 18028 KB Output is correct
22 Correct 1754 ms 17524 KB Output is correct
23 Correct 1681 ms 17064 KB Output is correct
24 Correct 1827 ms 18136 KB Output is correct
25 Correct 1857 ms 17988 KB Output is correct
26 Execution timed out 2081 ms 14132 KB Time limit exceeded
27 Halted 0 ms 0 KB -