# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
967912 | 2024-04-23T05:08:26 Z | duckindog | Boat (APIO16_boat) | C++17 | 2000 ms | 524288 KB |
#include <bits/stdc++.h> using namespace std; const int N = 500 + 10, M = 1'000'000'007; int n; int a[N], b[N]; int f[2][1'000'010]; auto add(auto& x, const auto& y) { x = (x + y) % M; } int32_t main() { cin.tie(0)->sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i] >> b[i]; vector<int> rrh; for (int i = 1; i <= n; ++i) { for (int j = a[i]; j <= b[i]; ++j) rrh.push_back(j); } sort(rrh.begin(), rrh.end()); rrh.resize(unique(rrh.begin(), rrh.end()) - rrh.begin()); f[0][0] = 1; for (int i = 1; i <= n; ++i) { int id = i & 1, p = id ^ 1; for (int j = 0; j <= rrh.size(); ++j) f[id][j] = 0; int it = lower_bound(rrh.begin(), rrh.end(), a[i]) - rrh.begin() + 1; for (int j = 0; j <= rrh.size(); ++j) f[id][j] = f[p][j]; for (int j = it; j <= b[i] - a[i] + it; ++j) { for (int t = 0; t < j; ++t) add(f[id][j], f[p][t]); } } int answer = 0; for (int i = 1; i <= rrh.size(); ++i) add(answer, f[n & 1][i]); cout << answer << "\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2648 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2392 KB | Output is correct |
11 | Correct | 1 ms | 2392 KB | Output is correct |
12 | Correct | 1 ms | 2392 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2396 KB | Output is correct |
15 | Correct | 1 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2392 KB | Output is correct |
17 | Correct | 1 ms | 2396 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2396 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2648 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2392 KB | Output is correct |
11 | Correct | 1 ms | 2392 KB | Output is correct |
12 | Correct | 1 ms | 2392 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2396 KB | Output is correct |
15 | Correct | 1 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2392 KB | Output is correct |
17 | Correct | 1 ms | 2396 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2396 KB | Output is correct |
21 | Execution timed out | 2041 ms | 6628 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 488 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2648 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2392 KB | Output is correct |
11 | Correct | 1 ms | 2392 KB | Output is correct |
12 | Correct | 1 ms | 2392 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2396 KB | Output is correct |
15 | Correct | 1 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2392 KB | Output is correct |
17 | Correct | 1 ms | 2396 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2396 KB | Output is correct |
21 | Execution timed out | 2041 ms | 6628 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |