# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
158263 | 2019-10-16T00:49:19 Z | maruii | Boat (APIO16_boat) | C++14 | 8 ms | 2296 KB |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; vector<int> xx(1); int f[505][505], s[505], g[505][505], A[505], B[505]; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int N; cin >> N; for (int i = 1; i <= N; ++i) { cin >> A[i] >> B[i]; B[i]++; xx.push_back(A[i]); xx.push_back(B[i]); } sort(xx.begin(), xx.end()); xx.erase(unique(xx.begin(), xx.end()), xx.end()); for (int i = 1; i <= N; ++i) { f[i - 1][0] = 1; s[0] = f[i - 1][0]; for (int j = 1; j + 1 < xx.size(); ++j) s[j] = (s[j - 1] + f[i - 1][j]) % mod; for (int j = 1; j + 1 < xx.size(); ++j) { if (A[i] <= xx[j] && xx[j + 1] <= B[i]) { f[i][j] = (s[j - 1] + g[i - 1][j]) % mod; g[i][j] = (1ll * (xx[j + 1] - xx[j]) * s[j - 1] + g[i - 1][j]) % mod; } } } int ans = 1; for (int i = 0; i + 1 < xx.size(); ++i) ans = (ans + f[N][i]) % mod; cout << ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 2296 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 2296 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 888 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 2296 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |