# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
68428 | 2018-08-17T06:34:42 Z | gusfring | Boat (APIO16_boat) | C++14 | 2000 ms | 525312 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 505, MOD = 1e9 + 7; typedef long long ll; typedef pair<int, int> pii; #define a first #define b second int N, A[MAXN], B[MAXN], T[1000505], bit[1000505], res, sum; vector<pii> vec; void update(int pos, int val){ while(pos <= sum){ bit[pos] = (bit[pos] + val) % MOD; pos += (pos & (-pos)); } } int query(int pos){ int r = 0; while(pos){ r = (r + bit[pos]) % MOD; pos -= (pos & (-pos)); } return r; } ll solve(){ int cnt = 0; for(int i=1; i<=N; ++i) for(int j=B[i]; j>=A[i]; --j) vec.push_back({j, ++cnt}); sort(vec.begin(), vec.end()); T[vec[0].b] = 1, cnt = 1; for(int i=1; i<vec.size(); ++i){ if(vec[i].a != vec[i - 1].a) cnt++; T[vec[i].b] = cnt; } for(int i=1; i<=sum; ++i){ int r = (query(T[i] - 1) + 1) % MOD; update(T[i], r); res = (res + r) % MOD; } return res; } int main(){ scanf("%d", &N); for(int i=1; i<=N; ++i){ scanf("%d %d", &A[i], &B[i]); sum += B[i] - A[i] + 1; } printf("%lld\n", solve()); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 504 KB | Output is correct |
3 | Correct | 4 ms | 504 KB | Output is correct |
4 | Correct | 3 ms | 520 KB | Output is correct |
5 | Correct | 3 ms | 596 KB | Output is correct |
6 | Correct | 2 ms | 608 KB | Output is correct |
7 | Correct | 3 ms | 620 KB | Output is correct |
8 | Correct | 4 ms | 688 KB | Output is correct |
9 | Correct | 3 ms | 828 KB | Output is correct |
10 | Correct | 3 ms | 828 KB | Output is correct |
11 | Correct | 3 ms | 828 KB | Output is correct |
12 | Correct | 3 ms | 896 KB | Output is correct |
13 | Correct | 2 ms | 896 KB | Output is correct |
14 | Correct | 3 ms | 896 KB | Output is correct |
15 | Correct | 4 ms | 896 KB | Output is correct |
16 | Correct | 3 ms | 904 KB | Output is correct |
17 | Correct | 3 ms | 916 KB | Output is correct |
18 | Correct | 4 ms | 984 KB | Output is correct |
19 | Correct | 2 ms | 996 KB | Output is correct |
20 | Correct | 3 ms | 1008 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 504 KB | Output is correct |
3 | Correct | 4 ms | 504 KB | Output is correct |
4 | Correct | 3 ms | 520 KB | Output is correct |
5 | Correct | 3 ms | 596 KB | Output is correct |
6 | Correct | 2 ms | 608 KB | Output is correct |
7 | Correct | 3 ms | 620 KB | Output is correct |
8 | Correct | 4 ms | 688 KB | Output is correct |
9 | Correct | 3 ms | 828 KB | Output is correct |
10 | Correct | 3 ms | 828 KB | Output is correct |
11 | Correct | 3 ms | 828 KB | Output is correct |
12 | Correct | 3 ms | 896 KB | Output is correct |
13 | Correct | 2 ms | 896 KB | Output is correct |
14 | Correct | 3 ms | 896 KB | Output is correct |
15 | Correct | 4 ms | 896 KB | Output is correct |
16 | Correct | 3 ms | 904 KB | Output is correct |
17 | Correct | 3 ms | 916 KB | Output is correct |
18 | Correct | 4 ms | 984 KB | Output is correct |
19 | Correct | 2 ms | 996 KB | Output is correct |
20 | Correct | 3 ms | 1008 KB | Output is correct |
21 | Correct | 223 ms | 11484 KB | Output is correct |
22 | Correct | 199 ms | 11484 KB | Output is correct |
23 | Correct | 198 ms | 11484 KB | Output is correct |
24 | Correct | 201 ms | 11756 KB | Output is correct |
25 | Correct | 273 ms | 11844 KB | Output is correct |
26 | Correct | 232 ms | 12412 KB | Output is correct |
27 | Correct | 241 ms | 12676 KB | Output is correct |
28 | Correct | 240 ms | 12756 KB | Output is correct |
29 | Correct | 270 ms | 12836 KB | Output is correct |
30 | Correct | 236 ms | 16812 KB | Output is correct |
31 | Correct | 220 ms | 16812 KB | Output is correct |
32 | Correct | 211 ms | 16832 KB | Output is correct |
33 | Correct | 209 ms | 16832 KB | Output is correct |
34 | Correct | 234 ms | 16832 KB | Output is correct |
35 | Correct | 171 ms | 16832 KB | Output is correct |
36 | Correct | 209 ms | 16832 KB | Output is correct |
37 | Correct | 190 ms | 16832 KB | Output is correct |
38 | Correct | 179 ms | 16832 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2052 ms | 525312 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 504 KB | Output is correct |
3 | Correct | 4 ms | 504 KB | Output is correct |
4 | Correct | 3 ms | 520 KB | Output is correct |
5 | Correct | 3 ms | 596 KB | Output is correct |
6 | Correct | 2 ms | 608 KB | Output is correct |
7 | Correct | 3 ms | 620 KB | Output is correct |
8 | Correct | 4 ms | 688 KB | Output is correct |
9 | Correct | 3 ms | 828 KB | Output is correct |
10 | Correct | 3 ms | 828 KB | Output is correct |
11 | Correct | 3 ms | 828 KB | Output is correct |
12 | Correct | 3 ms | 896 KB | Output is correct |
13 | Correct | 2 ms | 896 KB | Output is correct |
14 | Correct | 3 ms | 896 KB | Output is correct |
15 | Correct | 4 ms | 896 KB | Output is correct |
16 | Correct | 3 ms | 904 KB | Output is correct |
17 | Correct | 3 ms | 916 KB | Output is correct |
18 | Correct | 4 ms | 984 KB | Output is correct |
19 | Correct | 2 ms | 996 KB | Output is correct |
20 | Correct | 3 ms | 1008 KB | Output is correct |
21 | Correct | 223 ms | 11484 KB | Output is correct |
22 | Correct | 199 ms | 11484 KB | Output is correct |
23 | Correct | 198 ms | 11484 KB | Output is correct |
24 | Correct | 201 ms | 11756 KB | Output is correct |
25 | Correct | 273 ms | 11844 KB | Output is correct |
26 | Correct | 232 ms | 12412 KB | Output is correct |
27 | Correct | 241 ms | 12676 KB | Output is correct |
28 | Correct | 240 ms | 12756 KB | Output is correct |
29 | Correct | 270 ms | 12836 KB | Output is correct |
30 | Correct | 236 ms | 16812 KB | Output is correct |
31 | Correct | 220 ms | 16812 KB | Output is correct |
32 | Correct | 211 ms | 16832 KB | Output is correct |
33 | Correct | 209 ms | 16832 KB | Output is correct |
34 | Correct | 234 ms | 16832 KB | Output is correct |
35 | Correct | 171 ms | 16832 KB | Output is correct |
36 | Correct | 209 ms | 16832 KB | Output is correct |
37 | Correct | 190 ms | 16832 KB | Output is correct |
38 | Correct | 179 ms | 16832 KB | Output is correct |
39 | Execution timed out | 2052 ms | 525312 KB | Time limit exceeded |
40 | Halted | 0 ms | 0 KB | - |