# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
946525 | 2024-03-14T18:07:47 Z | n3rm1n | Boat (APIO16_boat) | C++17 | 2000 ms | 524288 KB |
/// boat #include<bits/stdc++.h> #define endl '\n' using namespace std; const int MAXN = 505, MAXX = 1e6+10; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n, m; int a[MAXN], b[MAXN]; unordered_map < int, int > id; vector < int > g, u; void read_hash() { cin >> n; for (int i = 1; i <= n; ++ i) { cin >> a[i] >> b[i]; for (int j = a[i]; j <= b[i]; ++ j) g.push_back(j); } sort(g.begin(), g.end()); u.push_back(g[0]); for (int i = 1; i < g.size(); ++ i) { if(u.back() != g[i]) u.push_back(g[i]); } for (int i = 0; i < u.size(); ++ i) { id[u[i]] = i+1; } } int dp[MAXX]; const int mod = 1e9 + 7; int pref[MAXX]; void solve() { int ans = 0; int maxx = u.size(); for (int i = 1; i <= n; ++ i) { for (int j = 1; j <= u.size(); ++ j) pref[j] = (pref[j-1] + dp[j]) % mod; for (int j = id[b[i]]; j >= id[a[i]]; -- j) { dp[j] += pref[j-1] + 1; dp[j] %= mod; } } for (int j = 1; j <= maxx; ++ j) pref[j] = (pref[j-1] + dp[j]) % mod; ans = pref[maxx]; ans %= mod; cout << ans << endl; } int main() { speed(); read_hash(); solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 2 ms | 348 KB | Output is correct |
3 | Correct | 2 ms | 348 KB | Output is correct |
4 | Correct | 2 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 348 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 2 ms | 348 KB | Output is correct |
9 | Correct | 2 ms | 348 KB | Output is correct |
10 | Correct | 2 ms | 348 KB | Output is correct |
11 | Correct | 2 ms | 348 KB | Output is correct |
12 | Correct | 2 ms | 348 KB | Output is correct |
13 | Correct | 2 ms | 344 KB | Output is correct |
14 | Correct | 2 ms | 348 KB | Output is correct |
15 | Correct | 2 ms | 344 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 2 ms | 348 KB | Output is correct |
3 | Correct | 2 ms | 348 KB | Output is correct |
4 | Correct | 2 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 348 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 2 ms | 348 KB | Output is correct |
9 | Correct | 2 ms | 348 KB | Output is correct |
10 | Correct | 2 ms | 348 KB | Output is correct |
11 | Correct | 2 ms | 348 KB | Output is correct |
12 | Correct | 2 ms | 348 KB | Output is correct |
13 | Correct | 2 ms | 344 KB | Output is correct |
14 | Correct | 2 ms | 348 KB | Output is correct |
15 | Correct | 2 ms | 344 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 48 ms | 4816 KB | Output is correct |
22 | Correct | 48 ms | 6352 KB | Output is correct |
23 | Correct | 48 ms | 5588 KB | Output is correct |
24 | Correct | 49 ms | 5332 KB | Output is correct |
25 | Correct | 50 ms | 5840 KB | Output is correct |
26 | Correct | 48 ms | 5840 KB | Output is correct |
27 | Correct | 54 ms | 4704 KB | Output is correct |
28 | Correct | 47 ms | 6612 KB | Output is correct |
29 | Correct | 48 ms | 6100 KB | Output is correct |
30 | Execution timed out | 2068 ms | 56512 KB | Time limit exceeded |
31 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 350 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 2 ms | 348 KB | Output is correct |
3 | Correct | 2 ms | 348 KB | Output is correct |
4 | Correct | 2 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 348 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 2 ms | 348 KB | Output is correct |
9 | Correct | 2 ms | 348 KB | Output is correct |
10 | Correct | 2 ms | 348 KB | Output is correct |
11 | Correct | 2 ms | 348 KB | Output is correct |
12 | Correct | 2 ms | 348 KB | Output is correct |
13 | Correct | 2 ms | 344 KB | Output is correct |
14 | Correct | 2 ms | 348 KB | Output is correct |
15 | Correct | 2 ms | 344 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 48 ms | 4816 KB | Output is correct |
22 | Correct | 48 ms | 6352 KB | Output is correct |
23 | Correct | 48 ms | 5588 KB | Output is correct |
24 | Correct | 49 ms | 5332 KB | Output is correct |
25 | Correct | 50 ms | 5840 KB | Output is correct |
26 | Correct | 48 ms | 5840 KB | Output is correct |
27 | Correct | 54 ms | 4704 KB | Output is correct |
28 | Correct | 47 ms | 6612 KB | Output is correct |
29 | Correct | 48 ms | 6100 KB | Output is correct |
30 | Execution timed out | 2068 ms | 56512 KB | Time limit exceeded |
31 | Halted | 0 ms | 0 KB | - |