Submission #3644293
Source Code Expand
#include <bits/stdc++.h> using namespace std; using ll = long long; #define repl(i,a,b) for(int i=(int)(a);(i)<(int)(b);++(i)) #define rep(i,n) repl(i,0,n) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x<<"="<<x<<endl #define fi first #define se second typedef pair<int,int> P; int N,M; vector<P> ps; int nxt[2000010][21]; int main(){ memset(nxt,-1,sizeof(nxt)); cin>>N>>M; rep(i,N){ int a,b; cin>>a>>b; if(a>b){ b+=M; } ps.push_back(P(a,b)); ps.push_back(P(a+M,b+M)); } sort(all(ps),[=](const P& a,const P& b){ return a.fi > b.fi; }); { set<int> st; int i = 0; for (int j = M * 2 - 1; j >= 0; j--) { while (i<(int)ps.size()&&ps[i].fi == j) { st.insert(ps[i].se); i++; } if (st.size() == 0) nxt[j][0] = -1; else nxt[j][0] = *st.begin(); } } rep(k,20){ rep(i,M*2){ if(nxt[i][k]==-1)nxt[i][k+1]=-1; else nxt[i][k+1]=nxt[nxt[i][k]][k]; } } int res=1; rep(i,N*2){ int a=ps[i].fi,b=ps[i].se; int lb=0,ub=N; while(ub-lb>1){ int X=(ub+lb)/2; int idx=b; rep(k,21){ if((X>>k)&1){ idx=nxt[idx][k]; if(idx==-1)break; } } if(idx!=-1&&idx<=a+M) lb=X; else ub=X; } res=max(res,lb+1); } cout<<res<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Anime Master |
User | WAsedAC1 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1647 Byte |
Status | RE |
Exec Time | 659 ms |
Memory | 175216 KB |
Judge Result
Set Name | All | ||||
---|---|---|---|---|---|
Score / Max Score | 0 / 100 | ||||
Status |
|
Set Name | Test Cases |
---|---|
All | 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 3, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 4, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 5, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 6, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 7, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 8, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 9 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
1 | MLE | 41 ms | 164352 KB |
10 | MLE | 42 ms | 164352 KB |
11 | MLE | 41 ms | 164352 KB |
12 | MLE | 42 ms | 164352 KB |
13 | MLE | 42 ms | 164352 KB |
14 | MLE | 41 ms | 164352 KB |
15 | MLE | 41 ms | 164352 KB |
16 | MLE | 42 ms | 164352 KB |
17 | MLE | 41 ms | 164352 KB |
18 | MLE | 41 ms | 164352 KB |
19 | MLE | 41 ms | 164352 KB |
2 | MLE | 41 ms | 164352 KB |
20 | MLE | 42 ms | 164352 KB |
21 | MLE | 41 ms | 164352 KB |
22 | MLE | 42 ms | 164352 KB |
23 | MLE | 41 ms | 164352 KB |
24 | MLE | 42 ms | 164352 KB |
25 | MLE | 41 ms | 164352 KB |
26 | MLE | 42 ms | 164352 KB |
27 | MLE | 42 ms | 164352 KB |
28 | MLE | 41 ms | 164352 KB |
29 | MLE | 42 ms | 164352 KB |
3 | MLE | 41 ms | 164352 KB |
30 | MLE | 41 ms | 164352 KB |
31 | MLE | 42 ms | 164352 KB |
32 | MLE | 41 ms | 164352 KB |
33 | MLE | 42 ms | 164352 KB |
34 | MLE | 41 ms | 164352 KB |
35 | MLE | 42 ms | 164352 KB |
36 | MLE | 42 ms | 164352 KB |
37 | MLE | 42 ms | 164352 KB |
38 | MLE | 42 ms | 164352 KB |
39 | MLE | 41 ms | 164352 KB |
4 | MLE | 41 ms | 164352 KB |
40 | MLE | 42 ms | 164352 KB |
41 | MLE | 42 ms | 164352 KB |
42 | MLE | 41 ms | 164352 KB |
43 | MLE | 41 ms | 164352 KB |
44 | MLE | 41 ms | 164352 KB |
45 | MLE | 41 ms | 164352 KB |
46 | MLE | 42 ms | 164352 KB |
47 | MLE | 41 ms | 164352 KB |
48 | MLE | 42 ms | 164352 KB |
49 | MLE | 41 ms | 164352 KB |
5 | MLE | 41 ms | 164352 KB |
50 | MLE | 42 ms | 164352 KB |
51 | MLE | 42 ms | 164352 KB |
52 | MLE | 42 ms | 164352 KB |
53 | MLE | 41 ms | 164352 KB |
54 | MLE | 41 ms | 164352 KB |
55 | MLE | 42 ms | 164352 KB |
56 | MLE | 41 ms | 164352 KB |
57 | MLE | 41 ms | 164352 KB |
58 | MLE | 621 ms | 175216 KB |
59 | MLE | 279 ms | 175216 KB |
6 | MLE | 41 ms | 164352 KB |
60 | MLE | 198 ms | 175216 KB |
61 | RE | 297 ms | 174832 KB |
62 | RE | 300 ms | 174832 KB |
63 | RE | 298 ms | 174832 KB |
64 | RE | 659 ms | 174832 KB |
65 | MLE | 145 ms | 167160 KB |
66 | MLE | 191 ms | 169460 KB |
67 | MLE | 250 ms | 167416 KB |
68 | MLE | 50 ms | 164736 KB |
69 | MLE | 51 ms | 164352 KB |
7 | MLE | 42 ms | 164352 KB |
70 | MLE | 57 ms | 164608 KB |
71 | MLE | 49 ms | 164352 KB |
72 | MLE | 48 ms | 164352 KB |
73 | MLE | 58 ms | 164352 KB |
74 | MLE | 49 ms | 164608 KB |
75 | MLE | 56 ms | 164736 KB |
76 | MLE | 67 ms | 165120 KB |
77 | MLE | 61 ms | 164736 KB |
78 | MLE | 59 ms | 164992 KB |
79 | MLE | 50 ms | 164608 KB |
8 | MLE | 42 ms | 164352 KB |
80 | MLE | 45 ms | 164480 KB |
81 | MLE | 50 ms | 164736 KB |
82 | MLE | 59 ms | 164864 KB |
83 | MLE | 56 ms | 164736 KB |
84 | MLE | 67 ms | 165372 KB |
85 | MLE | 64 ms | 165244 KB |
86 | MLE | 61 ms | 164736 KB |
87 | MLE | 58 ms | 164864 KB |
88 | MLE | 48 ms | 164608 KB |
89 | MLE | 59 ms | 165244 KB |
9 | MLE | 41 ms | 164352 KB |