# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
946526 | 2024-03-14T18:09:17 Z | n3rm1n | Boat (APIO16_boat) | C++17 | 1932 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 = id[b[i]]; j >= id[a[i]]; -- j) { dp[j] += pref[j-1] + 1; dp[j] %= mod; } for (int j = id[a[i]]; j <= u.size(); ++ 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 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 | 44 ms | 6356 KB | Output is correct |
22 | Correct | 44 ms | 5076 KB | Output is correct |
23 | Correct | 43 ms | 5588 KB | Output is correct |
24 | Correct | 45 ms | 4560 KB | Output is correct |
25 | Correct | 46 ms | 4816 KB | Output is correct |
26 | Correct | 46 ms | 6612 KB | Output is correct |
27 | Correct | 48 ms | 6352 KB | Output is correct |
28 | Correct | 48 ms | 5844 KB | Output is correct |
29 | Correct | 46 ms | 5072 KB | Output is correct |
30 | Correct | 1932 ms | 58412 KB | Output is correct |
31 | Correct | 1887 ms | 57224 KB | Output is correct |
32 | Correct | 1904 ms | 58044 KB | Output is correct |
33 | Correct | 1848 ms | 57168 KB | Output is correct |
34 | Correct | 1847 ms | 57404 KB | Output is correct |
35 | Correct | 1772 ms | 55228 KB | Output is correct |
36 | Correct | 1866 ms | 56908 KB | Output is correct |
37 | Correct | 1860 ms | 57288 KB | Output is correct |
38 | Correct | 1789 ms | 56736 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 435 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 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 | 44 ms | 6356 KB | Output is correct |
22 | Correct | 44 ms | 5076 KB | Output is correct |
23 | Correct | 43 ms | 5588 KB | Output is correct |
24 | Correct | 45 ms | 4560 KB | Output is correct |
25 | Correct | 46 ms | 4816 KB | Output is correct |
26 | Correct | 46 ms | 6612 KB | Output is correct |
27 | Correct | 48 ms | 6352 KB | Output is correct |
28 | Correct | 48 ms | 5844 KB | Output is correct |
29 | Correct | 46 ms | 5072 KB | Output is correct |
30 | Correct | 1932 ms | 58412 KB | Output is correct |
31 | Correct | 1887 ms | 57224 KB | Output is correct |
32 | Correct | 1904 ms | 58044 KB | Output is correct |
33 | Correct | 1848 ms | 57168 KB | Output is correct |
34 | Correct | 1847 ms | 57404 KB | Output is correct |
35 | Correct | 1772 ms | 55228 KB | Output is correct |
36 | Correct | 1866 ms | 56908 KB | Output is correct |
37 | Correct | 1860 ms | 57288 KB | Output is correct |
38 | Correct | 1789 ms | 56736 KB | Output is correct |
39 | Runtime error | 435 ms | 524288 KB | Execution killed with signal 9 |
40 | Halted | 0 ms | 0 KB | - |